#include <bits/stdc++.h>

#define ll long long
#define int long long
#define pii pair<int, int>
using namespace std;
const int maxn = 1e6+10;
const ll inf = 1e18;

template <typename _tp>
inline void read(_tp& x) {
    char ch = getchar(), sgn = 0;
    while (ch ^ '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') ch = getchar(), sgn = 1;
    for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
    if (sgn) x = -x;
}

bool judge(string s){
    int len = s.size();
    for(int i = 0; i < len/2; ++i){
        if(s[i] != s[len - i - 1])
            return false;
    }
    return true;
}
signed main(){
    string s;
    cin >> s;
    int sz = s.size();
    string str;
    for(int i = 2; i < sz; ++i){
        int num = 0;
        if(s[i] >= '0' && s[i] <= '9') num = s[i] - '0';
        else num = s[i] - 'A' + 10;
        string tmp;
        while(num){
            tmp += num % 2 + '0';
            num /= 2;
        }
        while(tmp.size() < 4) tmp += "0";
        str += tmp;
    }
    if(judge(str)) cout << "1";
    else cout << "0";
    //return 0;
}