#include<iostream> #include<cstring> #include<cmath> using namespace std; int main(){ string ch; int n; cin>>n>>ch; cout<<stoi(ch,0,n); }