#include <iostream>
#include <limits.h>
using namespace std;

int main() {
    string str;
    cin >> str;
    int flag = 1;
    size_t pos = 0;
    long long sum = 0;
    
    if('0' == str[pos])
    {
        goto end;
    }

    if('-' == str[pos])
    {
        flag = -1;
        ++pos;
    }
    while(pos < str.size())
    {
        if(str[pos] >= '0' && str[pos] <= '9')
        {
            sum = sum*10 + str[pos] - '0';
            ++pos;
        }
        else
        {
            goto end;
        }

    }
    sum *= flag;
    if(sum > INT_MAX || sum < INT_MIN) //引入头文件limits.h,该文件中定义了各种数据类型范围,相对于直接与具体某个数比较更具可移植性
    {
        goto end;
    }
    cout << sum << endl;
    
    return 0;
end:
    cout << 0 << endl;

    return 0;
}