program A322B
    implicit none
    integer(8)::N,i,ocount,zcount
    character(1000000)::S
    read*,S
    ocount=0
    zcount=0
    N=len_trim(S)

    do i=1,N
        if(S(i:i)=="0")ocount=ocount+1
        if(S(i:i)=="1")zcount=zcount+1
    end do

    print'(i0)',2*min(ocount,zcount)
end program A322B
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEs = internal global [1000000 x i8] undef
@_QQcl.840c1ae8043bc3db9de4aa0ec2f265fa = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4830/source.f\00"
@_QQcl.30 = linkonce constant [1 x i8] c"0"
@_QQcl.31 = linkonce constant [1 x i8] c"1"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.840c1ae8043bc3db9de4aa0ec2f265fa, i32 5)
  %2 = tail call i1 @_FortranAioInputAscii(ptr %1, ptr nonnull @_QFEs, i64 1000000)
  %3 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  br label %4

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 999999, %0 ], [ %9, %4 ]
  %6 = getelementptr [1000000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !3
  %8 = icmp eq i8 %7, 32
  %9 = add nsw i64 %5, -1
  %10 = icmp ne i64 %5, 0
  %11 = and i1 %8, %10
  br i1 %11, label %4, label %12

12:                                               ; preds = %4
  %13 = shl i64 %5, 32
  %sext = add i64 %13, 4294967296
  %14 = ashr exact i64 %sext, 32
  %spec.select12 = select i1 %8, i64 0, i64 %14
  %15 = icmp sgt i64 %spec.select12, 0
  br i1 %15, label %select.unfold, label %select.unfold._crit_edge

select.unfold:                                    ; preds = %12, %select.unfold
  %16 = phi i64 [ %25, %select.unfold ], [ 1, %12 ]
  %.015 = phi i64 [ %.1, %select.unfold ], [ 0, %12 ]
  %.0814 = phi i64 [ %spec.select, %select.unfold ], [ 0, %12 ]
  %17 = add nsw i64 %16, -1
  %18 = getelementptr [1000000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %17
  %19 = tail call i32 @_FortranACharacterCompareScalar1(ptr %18, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %20 = icmp eq i32 %19, 0
  %21 = zext i1 %20 to i64
  %spec.select = add i64 %.0814, %21
  %22 = tail call i32 @_FortranACharacterCompareScalar1(ptr %18, ptr nonnull @_QQcl.31, i64 1, i64 1)
  %23 = icmp eq i32 %22, 0
  %24 = zext i1 %23 to i64
  %.1 = add i64 %.015, %24
  %25 = add nuw nsw i64 %16, 1
  %exitcond.not = icmp eq i64 %16, %spec.select12
  br i1 %exitcond.not, label %select.unfold._crit_edge, label %select.unfold

select.unfold._crit_edge:                         ; preds = %select.unfold, %12
  %.08.lcssa = phi i64 [ 0, %12 ], [ %spec.select, %select.unfold ]
  %.0.lcssa = phi i64 [ 0, %12 ], [ %.1, %select.unfold ]
  %26 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.840c1ae8043bc3db9de4aa0ec2f265fa, i32 15)
  %27 = tail call i64 @llvm.smin.i64(i64 %.08.lcssa, i64 %.0.lcssa)
  %28 = shl i64 %27, 1
  %29 = tail call i1 @_FortranAioOutputInteger64(ptr %26, i64 %28)
  %30 = tail call i32 @_FortranAioEndIoStatement(ptr %26)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
