#include<iostream>
#include<stack>
using namespace std;
int main() {
    int num_Hex;
    stack<int> s;        //用栈保存余数
    while(cin>>hex>>num_Hex) {    //要获取16进制输入必须要以cin>>hex>>这种形式,否则无法正确获取输入的16进制数
        while(num_Hex) {        //当num_hex不为0
            s.push(num_Hex%10);    //余数进栈
            num_Hex = num_Hex / 10;    //除以要转化的进制
        }
        while(!s.empty()) {    //当栈不为空
            cout<<s.top();    //依次输出栈顶元素并出栈
            s.pop();
        }
        cout<<endl;    //换行输出
    }
    return 0;
}