n, k = map(int, input().split())
l = list(map(int, input().split()))
tree = {0: -1}
su = 0
res = 0
for i in range(len(l)):
su += l[i]
if su in tree:
tree[su] = min(tree[su], i)
else:
tree[su] = i
if su - k in tree:
res = max(i - tree[su - k], res)
print(res)