#include <iostream>
using namespace std;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int M, A;
cin >> M >> A;
bool stop = false;
for (int i = 0; i<M; i++)
{
int tmp;
cin >> tmp;
if (A > tmp && !stop) A += tmp;
else stop = true;
}
cout << A << "\n";
}