#include<cstring>#include<iostream>#include<algorithm>usingnamespace std;
string str;int a[11000];int cnt;intqin(string n,int w){int res =0;for(int i =0; i < n.size(); i ++){if(n[i]<='9'&& n[i]>='0') res = res * w +(n[i]-'0');elseif(n[i]>='A'&& n[i]<='Z') res = res * w +(n[i]-'A'+10);elseif(n[i]>='a'&& n[i]<='z') res = res * w +(n[i]-'a'+36);}return res;}intConvert(int n,int b){while(n){
a[cnt++]= n % b;
n = n / b;}}intmain(){
cin >> str;int num =qin(str,16);
cout << num << endl;Convert(num,3);for(int i = cnt -1; i >=0; i --)
cout << a[i];}