program tiles
  implicit none
  integer :: i,j,k,N,dif
  character(len=100000) :: S,Sp
  character :: ss

  read(*,*) S
  N=len_trim(S)

  dif=0
  ! comp with                                                                   
  do i=1,N
     j=mod(i,2)
     !write(*,*) j                                                              
     Sp=trim(S)
     ss=Sp(i:i)
     read(ss,*) k
     if(j.eq.k) then
!        write(*,*) "onaji"                                                     
     else
!        write(*,*) "dif"                                                       
        dif=dif+1
     endif
  enddo
  if((N-dif).lt.dif) then
     dif=N-dif
  endif
  write(*,'(i0)') dif

end program tiles


; 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 [100000 x i8] undef
@_QFEsp = internal unnamed_addr global [100000 x i8] undef
@_QQcl.d9248eacd7dade8d039e14a58f9c2dfd = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4500/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %3 = alloca i32, align 4
  %4 = alloca [1 x i8], align 1
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.d9248eacd7dade8d039e14a58f9c2dfd, i32 7)
  %6 = tail call i1 @_FortranAioInputAscii(ptr %5, ptr nonnull @_QFEs, i64 100000)
  %7 = tail call i32 @_FortranAioEndIoStatement(ptr %5)
  br label %8

8:                                                ; preds = %0, %8
  %9 = phi i64 [ 99999, %0 ], [ %13, %8 ]
  %10 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !3
  %12 = icmp eq i8 %11, 32
  %13 = add nsw i64 %9, -1
  %14 = icmp ne i64 %9, 0
  %15 = and i1 %12, %14
  br i1 %15, label %8, label %16

16:                                               ; preds = %8
  %17 = trunc i64 %9 to i32
  %18 = add i32 %17, 1
  %19 = select i1 %12, i32 0, i32 %18
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph67, label %._crit_edge68

.lr.ph67:                                         ; preds = %16
  %21 = zext i32 %19 to i64
  %.fca.1.gep20 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 1
  %.fca.2.gep21 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 2
  %.fca.3.gep22 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 3
  %.fca.4.gep23 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 4
  %.fca.5.gep24 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 5
  %.fca.6.gep25 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 6
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 6
  br label %22

22:                                               ; preds = %.lr.ph67, %._crit_edge
  %indvars.iv = phi i64 [ 1, %.lr.ph67 ], [ %indvars.iv.next, %._crit_edge ]
  %.065 = phi i32 [ 0, %.lr.ph67 ], [ %.1, %._crit_edge ]
  %23 = trunc i64 %indvars.iv to i32
  %.urem = and i32 %23, 1
  store ptr @_QFEs, ptr %1, align 8, !tbaa !7
  store i64 100000, ptr %.fca.1.gep20, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep21, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep22, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep23, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep24, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep25, align 1, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep, align 1, !tbaa !7
  store i8 2, ptr %.fca.5.gep, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %24 = call {} @_FortranATrim(ptr nonnull %2, ptr nonnull %1, ptr nonnull @_QQcl.d9248eacd7dade8d039e14a58f9c2dfd, i32 15)
  %.fca.0.load = load ptr, ptr %2, align 8, !tbaa !7
  %.fca.1.load = load i64, ptr %.fca.1.gep, align 8, !tbaa !7
  %25 = call i64 @llvm.smin.i64(i64 %.fca.1.load, i64 100000)
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 16 @_QFEsp, ptr align 1 %.fca.0.load, i64 %25, i1 false)
  %26 = sub i64 100000, %25
  %27 = icmp sgt i64 %26, 0
  br i1 %27, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %22
  %uglygep = getelementptr i8, ptr @_QFEsp, i64 %25
  call void @llvm.memset.p0.i64(ptr align 1 %uglygep, i8 32, i64 %26, i1 false), !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %22
  call void @free(ptr %.fca.0.load)
  %28 = add nsw i64 %indvars.iv, -1
  %29 = getelementptr [100000 x [1 x i8]], ptr @_QFEsp, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1
  store i8 %30, ptr %4, align 1
  %31 = call ptr @_FortranAioBeginInternalListInput(ptr nonnull %4, i64 1, ptr null, i64 0, ptr nonnull @_QQcl.d9248eacd7dade8d039e14a58f9c2dfd, i32 17)
  %32 = call i1 @_FortranAioInputInteger(ptr %31, ptr nonnull %3, i32 4)
  %33 = call i32 @_FortranAioEndIoStatement(ptr %31)
  %34 = load i32, ptr %3, align 4, !tbaa !3
  %35 = icmp ne i32 %.urem, %34
  %36 = zext i1 %35 to i32
  %.1 = add i32 %.065, %36
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %21
  br i1 %exitcond.not, label %._crit_edge68, label %22

._crit_edge68:                                    ; preds = %._crit_edge, %16
  %.0.lcssa = phi i32 [ 0, %16 ], [ %.1, %._crit_edge ]
  %37 = sub i32 %19, %.0.lcssa
  %spec.select = call i32 @llvm.smin.i32(i32 %37, i32 %.0.lcssa)
  %38 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.d9248eacd7dade8d039e14a58f9c2dfd, i32 28)
  %39 = call i1 @_FortranAioOutputInteger32(ptr %38, i32 %spec.select)
  %40 = call i32 @_FortranAioEndIoStatement(ptr %38)
  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 {} @_FortranATrim(ptr, ptr, ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

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

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
