#include<iostream> using namespace std; int main() { long long x,k; cin>>x>>k; for(long long i=1;i<=k;i++) { x++; if(x%3==0)x=x/3; } cout<<x; }