#include<bits/stdc++.h>
using namespace std;
string to_16[8]={"000","001","010","011","100","101","110","111"};
int main(){
string a,_2;
cin>>a;
int l=a.length();
for(int i=0;i<l;i++){
_2+=to_16[a[i]-'0'];
}
bool b=true;
l=_2.length();
reverse(_2.begin(),_2.end());
for(int i=l/4*4;i>=0;i-=4){
string _16;_16+=_2[i+3];_16+=_2[i+2];_16+=_2[i+1];_16+=_2[i];
if(_16=="0000"&&!b){
cout<<0;
}else if(_16=="0001"){
cout<<1;
b=false;
}else if(_16=="0010"){
cout<<2;
b=false;
}else if(_16=="0011"){
cout<<3;
b=false;
}else if(_16=="0100"){
cout<<4;
b=false;
}else if(_16=="0101"){
cout<<5;
b=false;
}else if(_16=="0110"){
cout<<6;
b=false;
}else if(_16=="0111"){
cout<<7;
b=false;
}else if(_16=="1000"){
cout<<8;
b=false;
}else if(_16=="1001"){
cout<<9;
b=false;
}else if(_16=="1010"){
cout<<'a';
b=false;
}else if(_16=="1011"){
cout<<'b';
b=false;
}else if(_16=="1100"){
cout<<'c';
b=false;
}else if(_16=="1101"){
cout<<'d';
b=false;
}else if(_16=="1110"){
cout<<'e';
b=false;
}else if(_16=="1111"){
cout<<'f';
b=false;
}
}
if(b){
cout<<0;
}
return 0;
}