program main
implicit none
character :: s*100000
integer   :: i, l, res, iloop, chk( 2 )

read(*,*) s
l = len_trim( s )

do iloop = 1, 2

if( iloop == 1 ) then
   res = 0
else
   res = 1
   if( s(1:1) == '0' ) then
      s(1:1) = '1'
   else
      s(1:1) = '0'
   end if
end if
do i = 2, l
   if( s(i:i) /= s(i-1:i-1) ) then
   else if( i == 2 ) then
      if( s(i-1:i-1) =='0')then
         s(i:i) = '1'
      else
         s(i:i) = '0'
      end if
      res = res + 1
   else
      s(i:i) = s(i-2:i-2)
      res = res + 1
   end if
end do
chk( iloop ) = res
end do

write(*,'(i0)') minval( chk )

end program main

; 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
@_QQcl.549906316bb895ac0ea79fa0728551cd = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4498/source.f\00"
@_QQcl.30 = linkonce constant [1 x i8] c"0"
@_QQcl.31 = linkonce local_unnamed_addr 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 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca [2 x i32], align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.549906316bb895ac0ea79fa0728551cd, i32 6)
  %4 = tail call i1 @_FortranAioInputAscii(ptr %3, ptr nonnull @_QFEs, i64 100000)
  %5 = tail call i32 @_FortranAioEndIoStatement(ptr %3)
  br label %64

.preheader:                                       ; preds = %64
  %6 = load i8, ptr @_QQcl.30, align 1
  %7 = load i8, ptr @_QQcl.31, align 1
  %8 = shl i64 %65, 32
  %sext = add i64 %8, 4294967296
  %9 = ashr exact i64 %sext, 32
  %.op = add nsw i64 %9, -1
  %spec.select = select i1 %68, i64 -1, i64 %.op
  %spec.select.fr = freeze i64 %spec.select
  %10 = icmp sgt i64 %spec.select.fr, 0
  br i1 %10, label %.lr.ph.us, label %.split.us.loopexit25

.lr.ph.us:                                        ; preds = %.preheader, %select.unfold.us
  %11 = phi i64 [ %34, %select.unfold.us ], [ %spec.select.fr, %.preheader ]
  %12 = phi i32 [ %33, %select.unfold.us ], [ 2, %.preheader ]
  %.124.us = phi i32 [ %.2.us, %select.unfold.us ], [ 0, %.preheader ]
  %13 = sext i32 %12 to i64
  %14 = add nsw i64 %13, -1
  %15 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %14
  %16 = add i32 %12, -1
  %17 = sext i32 %16 to i64
  %18 = add nsw i64 %17, -1
  %19 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %18
  %20 = tail call i32 @_FortranACharacterCompareScalar1(ptr %15, ptr %19, i64 1, i64 1)
  %.not.us = icmp eq i32 %20, 0
  br i1 %.not.us, label %21, label %select.unfold.us

21:                                               ; preds = %.lr.ph.us
  %22 = icmp eq i32 %12, 2
  br i1 %22, label %29, label %23

23:                                               ; preds = %21
  %24 = add i32 %12, -2
  %25 = sext i32 %24 to i64
  %26 = add nsw i64 %25, -1
  %27 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %26
  %28 = load i8, ptr %27, align 1
  br label %select.unfold.us.sink.split

29:                                               ; preds = %21
  %30 = tail call i32 @_FortranACharacterCompareScalar1(ptr %19, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %31 = icmp eq i32 %30, 0
  %storemerge.us = select i1 %31, i8 %7, i8 %6
  br label %select.unfold.us.sink.split

select.unfold.us.sink.split:                      ; preds = %23, %29
  %storemerge.us.sink = phi i8 [ %storemerge.us, %29 ], [ %28, %23 ]
  store i8 %storemerge.us.sink, ptr %15, align 1
  %32 = add i32 %.124.us, 1
  br label %select.unfold.us

select.unfold.us:                                 ; preds = %select.unfold.us.sink.split, %.lr.ph.us
  %.2.us = phi i32 [ %.124.us, %.lr.ph.us ], [ %32, %select.unfold.us.sink.split ]
  %33 = add i32 %12, 1
  %34 = add nsw i64 %11, -1
  %35 = icmp sgt i64 %11, 1
  br i1 %35, label %.lr.ph.us, label %.lr.ph.us.1

.lr.ph.us.1:                                      ; preds = %select.unfold.us
  store i32 %.2.us, ptr %2, align 4, !tbaa !3
  %36 = tail call i32 @_FortranACharacterCompareScalar1(ptr nonnull @_QFEs, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %37 = icmp eq i32 %36, 0
  %spec.select31 = select i1 %37, i8 %7, i8 %6
  store i8 %spec.select31, ptr @_QFEs, align 16
  br label %38

38:                                               ; preds = %select.unfold.us.1, %.lr.ph.us.1
  %39 = phi i64 [ %spec.select.fr, %.lr.ph.us.1 ], [ %62, %select.unfold.us.1 ]
  %40 = phi i32 [ 2, %.lr.ph.us.1 ], [ %61, %select.unfold.us.1 ]
  %.124.us.1 = phi i32 [ 1, %.lr.ph.us.1 ], [ %.2.us.1, %select.unfold.us.1 ]
  %41 = sext i32 %40 to i64
  %42 = add nsw i64 %41, -1
  %43 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %42
  %44 = add i32 %40, -1
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %45, -1
  %47 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %46
  %48 = tail call i32 @_FortranACharacterCompareScalar1(ptr %43, ptr %47, i64 1, i64 1)
  %.not.us.1 = icmp eq i32 %48, 0
  br i1 %.not.us.1, label %49, label %select.unfold.us.1

49:                                               ; preds = %38
  %50 = icmp eq i32 %40, 2
  br i1 %50, label %57, label %51

51:                                               ; preds = %49
  %52 = add i32 %40, -2
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %53, -1
  %55 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1
  br label %select.unfold.us.1.sink.split

57:                                               ; preds = %49
  %58 = tail call i32 @_FortranACharacterCompareScalar1(ptr %47, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %59 = icmp eq i32 %58, 0
  %storemerge.us.1 = select i1 %59, i8 %7, i8 %6
  br label %select.unfold.us.1.sink.split

select.unfold.us.1.sink.split:                    ; preds = %51, %57
  %storemerge.us.1.sink = phi i8 [ %storemerge.us.1, %57 ], [ %56, %51 ]
  store i8 %storemerge.us.1.sink, ptr %43, align 1
  %60 = add i32 %.124.us.1, 1
  br label %select.unfold.us.1

select.unfold.us.1:                               ; preds = %select.unfold.us.1.sink.split, %38
  %.2.us.1 = phi i32 [ %.124.us.1, %38 ], [ %60, %select.unfold.us.1.sink.split ]
  %61 = add i32 %40, 1
  %62 = add nsw i64 %39, -1
  %63 = icmp sgt i64 %39, 1
  br i1 %63, label %38, label %.split.us

64:                                               ; preds = %0, %64
  %65 = phi i64 [ 99999, %0 ], [ %69, %64 ]
  %66 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !3
  %68 = icmp eq i8 %67, 32
  %69 = add nsw i64 %65, -1
  %70 = icmp ne i64 %65, 0
  %71 = and i1 %68, %70
  br i1 %71, label %64, label %.preheader

.split.us.loopexit25:                             ; preds = %.preheader
  store i32 0, ptr %2, align 4, !tbaa !3
  %72 = tail call i32 @_FortranACharacterCompareScalar1(ptr nonnull @_QFEs, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %73 = icmp eq i32 %72, 0
  %spec.select32 = select i1 %73, i8 %7, i8 %6
  store i8 %spec.select32, ptr @_QFEs, align 16
  br label %.split.us

.split.us:                                        ; preds = %select.unfold.us.1, %.split.us.loopexit25
  %.sink = phi i32 [ 1, %.split.us.loopexit25 ], [ %.2.us.1, %select.unfold.us.1 ]
  %74 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 1
  store i32 %.sink, ptr %74, align 4, !tbaa !3
  %75 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.549906316bb895ac0ea79fa0728551cd, i32 38)
  store ptr %2, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 2, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %76 = call i32 @_FortranAMinvalInteger4(ptr nonnull %1, ptr nonnull @_QQcl.549906316bb895ac0ea79fa0728551cd, i32 38, i32 0, ptr null)
  %77 = call i1 @_FortranAioOutputInteger32(ptr %75, i32 %76)
  %78 = call i32 @_FortranAioEndIoStatement(ptr %75)
  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 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

!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}
