import std.algorithm, std.array, std.container, std.range; import std.numeric, std.math, std.bigint, std.bitmanip, std.random; import std.string, std.conv, std.stdio, std.typecons; void main() { auto rd = readln.split.map!(to!int); auto n = rd[0], m = rd[1]; auto ci = readln.split.map!(to!int).array; ci.sort(); writeln(calc(m, ci)); } int calc(int m, int[] ci) { auto r = 0; auto s = 0; foreach (c; ci) { r += 1; s += c; if (s > m) return r - 1; } return r; }