#!/usr/bin/env python3 # † from collections import Counter, deque ### if __name__ == '__main__': N, W = map(int, input().split()) a = [int(input()) for _ in range(N)] deq = deque() acc = 0 cnt = Counter() maxi = 0 size = 0 for ai in a: deq.append(ai) acc += ai cnt[ai] += 1 size += 1 while cnt[ai] > 1 or W < acc: top = deq.popleft() cnt[top] -= 1 acc -= top size -= 1 maxi = max(maxi, size) print(maxi)