#!/usr/bin/env python # -*- coding: utf-8 -*- def PutBlock(L, N, Wi): count = 0 Wi.sort() for i in range(N): if L >= Wi[i]: L -= Wi[i] count += 1 else: break return count def main(): L = int(input()) N = int(input()) Wi = list(map(int, input().split())) print(PutBlock(L, N, Wi)) print(L, N) print(Wi) if __name__ == '__main__': main()