import Foundation
let num = readLine()!.components(separatedBy: " ").map { Int($0)! }
var arr = readLine()!.components(separatedBy: " ").map { Int($0)! }
var result: [Int] = []
func log(_ size: Int) {
var ar: [Int] = []
for i in 0..<size {
ar.append(arr[i])
}
result.append(ar.reduce(0, +))
}
func permutation(_ n: Int, _ r: Int, _ depth: Int) {
if r == depth {
log(depth)
return
}
for i in depth..<n {
arr.swapAt(i, depth)
permutation(n,r,depth + 1)
arr.swapAt(i, depth)
}
}
permutation(arr.count,3,0)
print(result.filter { $0 <= num[1] }.max()!)