def max_polygons(n, x, a) l, t, m = 0, 0, 0 for r in 0...n t += a[r] while t > x t -= a[l] l += 1 end m = [m, t].max end m end n, x = gets.split.map(&:to_i) a = gets.split.map(&:to_i) puts max_polygons(n, x, a)