n, s = map(int, input().split())
a = list(map(int, input().split()))
left = 0
right = 0
ans = n + 1 + s
tmp_sum = a[left]
loopout = False
while True:
if tmp_sum >= s:
ans = min(ans, right-left+1)
if left == right:
right += 1
if right == n:
loopout = True
break
tmp_sum += a[right]
else:
tmp_sum -= a[left]
left += 1
else:
right += 1
if right == n:
loopout = True
break
tmp_sum += a[right]
if loopout == True:
break
if ans == n + 1 + s:
print(0)
else:
print(ans)
투포인터로 풀어봤다