#include <bits/stdc++.h>
using namespace std;
int main(){
int x;
int was = 0;
int ans = 0;
while(cin >> x){
if(x == 0)was = 1;
if(was == 0)ans = max(ans,x);
}
cout << ans;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpewoJaW50IHg7CglpbnQgd2FzID0gMDsKCWludCBhbnMgPSAwOwoJd2hpbGUoY2luID4+IHgpewogICAgICAgIGlmKHggPT0gMCl3YXMgPSAxOwogICAgICAgIGlmKHdhcyA9PSAwKWFucyA9IG1heChhbnMseCk7Cgl9Cgljb3V0IDw8IGFuczsKfQ==