from collections import * N, W = map(int, input().split()) Q = deque() D = defaultdict(int) ans = 0 S = 0 for i in range(N): A = int(input()) D[A] += 1 S += A Q.append(A) while D[A] == 2 or S > W: B = Q.popleft() D[B] -= 1 S -= B ans = max(ans, len(Q)) print(ans)