input_list = list(map(int,input().split())) n, k = input_list a_list = [] a_list = [int(input()) for i in range(n)] target = k res = 0 while True: cur_list = [e for e in a_list if e <= target] if not cur_list: break else: res += max(cur_list) target -= max(cur_list) print(res)