integer N,X
integer location
integer ans
integer,allocatable,dimension(:)::L
read*,N,X
allocate(L(N+1))
L(1)=0
read*,L(2:N+1)

ans=0
location=0
do i=1,N+1
  location=location+L(i)
  if(location>X)exit
  ans=ans+1
end do

print"(i0)",ans

end
; 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"

@_QFEl.0 = internal unnamed_addr global ptr null
@_QQcl.7d9c75e32b2b19b21ad18506a13a0edf = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3997/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7d9c75e32b2b19b21ad18506a13a0edf, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 4)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i32, ptr %2, align 4, !tbaa !3
  %9 = add i32 %8, 1
  %10 = call i32 @llvm.smax.i32(i32 %9, i32 0)
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  %13 = call ptr @malloc(i64 %12)
  store ptr %13, ptr @_QFEl.0, align 8, !tbaa !7
  store i32 0, ptr %13, align 4, !tbaa !3
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7d9c75e32b2b19b21ad18506a13a0edf, i32 8)
  %.unpack = load ptr, ptr @_QFEl.0, align 8, !tbaa !7
  %15 = load i32, ptr %2, align 4, !tbaa !3
  %16 = add i32 %15, 1
  %17 = call i32 @llvm.smax.i32(i32 %16, i32 1)
  %18 = zext i32 %17 to i64
  %19 = add nsw i64 %18, -1
  %20 = getelementptr i32, ptr %.unpack, i64 1
  store ptr %20, 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 %19, 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
  %21 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %1)
  %22 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %23 = load i32, ptr %2, align 4, !tbaa !3
  %24 = icmp ult i32 %23, 2147483647
  br i1 %24, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %25 = add nuw nsw i32 %23, 1
  %.unpack119 = load ptr, ptr @_QFEl.0, align 8, !tbaa !7
  %26 = load i32, ptr %3, align 4, !tbaa !3
  br label %27

27:                                               ; preds = %.lr.ph, %34
  %.0134 = phi i32 [ 0, %.lr.ph ], [ %32, %34 ]
  %.095133 = phi i32 [ 1, %.lr.ph ], [ %37, %34 ]
  %.096132 = phi i32 [ 0, %.lr.ph ], [ %35, %34 ]
  %.097131 = phi i32 [ %25, %.lr.ph ], [ %36, %34 ]
  %28 = sext i32 %.095133 to i64
  %29 = add nsw i64 %28, -1
  %30 = getelementptr i32, ptr %.unpack119, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !3
  %32 = add i32 %31, %.0134
  %33 = icmp sgt i32 %32, %26
  br i1 %33, label %._crit_edge, label %34

34:                                               ; preds = %27
  %35 = add nuw nsw i32 %.096132, 1
  %36 = add nsw i32 %.097131, -1
  %37 = add nuw i32 %.095133, 1
  %38 = icmp sgt i32 %.097131, 1
  br i1 %38, label %27, label %._crit_edge

._crit_edge:                                      ; preds = %34, %27, %0
  %.096.lcssa = phi i32 [ 0, %0 ], [ %.096132, %27 ], [ %35, %34 ]
  %39 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.7d9c75e32b2b19b21ad18506a13a0edf, i32 18)
  %40 = call i1 @_FortranAioOutputInteger32(ptr %39, i32 %.096.lcssa)
  %41 = call i32 @_FortranAioEndIoStatement(ptr %39)
  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 i1 @_FortranAioInputDescriptor(ptr, ptr) 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 i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { 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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
