import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, x = map(int, input().split())
        a = list(map(int, input().split()))

        a.sort()
        ans = 0
        for child in a:
            x -= child
            if x == 0:
                ans += 1
                break
            elif x < 0:
                break
            else:
                ans += 1
        if x != 0:
            ans -= 1
        print(min(0, ans))


if __name__ == '__main__':
    AtCoder().main()
