#include <iostream>
using namespace std;
int main() {
int max1, max2, temp, x;
cin>>max1>>max2;
if(max1<max2){
temp = max1;
max1 = max2;
max2 = temp;
}
if(max2 !=0){
while(cin>>x){
if(x!=0){
if(x>max1){
max2 = max1; max1 = x;
}
if(x> max2 && x < max1){
max2 = x;
}
}
else{
break;
}
}
}
cout<<max2;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbWF4MSwgbWF4MiwgdGVtcCwgeDsKCQoJY2luPj5tYXgxPj5tYXgyOwoJCglpZihtYXgxPG1heDIpewoJCXRlbXAgPSBtYXgxOwoJCW1heDEgPSBtYXgyOwoJCW1heDIgPSB0ZW1wOwoJfQoJaWYobWF4MiAhPTApewoJCXdoaWxlKGNpbj4+eCl7CgkJCWlmKHghPTApewoJCQlpZih4Pm1heDEpewoJCQkJbWF4MiA9IG1heDE7IG1heDEgPSB4OwoJCQl9CgkJCWlmKHg+IG1heDIgJiYgeCA8IG1heDEpewoJCQkJbWF4MiA9IHg7CgkJCX0KCQl9CgkJZWxzZXsKCQkJYnJlYWs7CgkJfQoJCX0KCX0KCWNvdXQ8PG1heDI7CgoJcmV0dXJuIDA7Cn0=