#include <iostream>
#include <string>
 
using namespace std;
 
int str_to_int(string a);
 
int main() {
    string s = "9999XxX999";
    cout << str_to_int(s);
}
 
int str_to_int(string a) {
    int num = 0;
    int tmp;
    bool anti = false;
    double l = 1;
 
    for(int i = a.size() - 1; i >= 0; --i, l *= 10) {
        if(a[i] == '0') {tmp = 0;}
 
        if(a[i] >= '0' && a[i] <= '9') {tmp = a[i] - '0';}
 
        else if(i == 0 && a[i] == '-') {anti = true; break;}
 
 
        else {
                return 0;
        }
 
        num += (tmp * l);
    }
 
    if(anti == true) {return -num;}
    else {return num;}
}