program main
	implicit none
    integer N, K
	read(*, *) N, K
	if(N == K) then
		write(*, *) 1
	else if(mod(N-K,K-1) == 0) then
		write(*, *) (N-K)/(K-1) + 1
	else
		write(*, *) (N-K)/(K-1) + 2
	end if
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"

@_QQcl.694f501d7e3f4b2e104c0688c4f421cf = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5834/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.694f501d7e3f4b2e104c0688c4f421cf, i32 4)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = load i32, ptr %1, align 4, !tbaa !3
  %9 = icmp eq i32 %7, %8
  br i1 %9, label %10, label %13

10:                                               ; preds = %0
  %11 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.694f501d7e3f4b2e104c0688c4f421cf, i32 6)
  %12 = call i1 @_FortranAioOutputInteger32(ptr %11, i32 1)
  br label %36

13:                                               ; preds = %0
  %14 = sub i32 %7, %8
  %15 = add i32 %8, -1
  %16 = srem i32 %14, %15
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %27

18:                                               ; preds = %13
  %19 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.694f501d7e3f4b2e104c0688c4f421cf, i32 8)
  %20 = load i32, ptr %2, align 4, !tbaa !3
  %21 = load i32, ptr %1, align 4, !tbaa !3
  %22 = sub i32 %20, %21
  %23 = add i32 %21, -1
  %24 = sdiv i32 %22, %23
  %25 = add i32 %24, 1
  %26 = call i1 @_FortranAioOutputInteger32(ptr %19, i32 %25)
  br label %36

27:                                               ; preds = %13
  %28 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.694f501d7e3f4b2e104c0688c4f421cf, i32 10)
  %29 = load i32, ptr %2, align 4, !tbaa !3
  %30 = load i32, ptr %1, align 4, !tbaa !3
  %31 = sub i32 %29, %30
  %32 = add i32 %30, -1
  %33 = sdiv i32 %31, %32
  %34 = add i32 %33, 2
  %35 = call i1 @_FortranAioOutputInteger32(ptr %28, i32 %34)
  br label %36

36:                                               ; preds = %10, %18, %27
  %.sink = phi ptr [ %11, %10 ], [ %19, %18 ], [ %28, %27 ]
  %37 = call i32 @_FortranAioEndIoStatement(ptr %.sink)
  ret void
}

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

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

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) 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"}
