1 #include<iostream>
2 #include<queue>
3 #include<bits/stdc++.h>
4 using namespace std;
5 int tot=1;
6 int x;
7 int main()
8 {
9 int x,n;
10 while(cin>>x&&cin>>n)
11 {
12 tot=1;
13 queue<int>a;
14 queue<int>b;
15 while(tot<n)
16 {
17 a.push(2*x+1);
18 b.push(3*x+1);
19 if(a.front()>b.front())
20 {
21 x=b.front();
22 b.pop();
23 }
24 else if(a.front()<b.front())
25 {
26 x=a.front();
27 a.pop();
28 }
29 else
30 {
31 x=a.front();
32 a.pop();
33 b.pop();
34 }
35 tot++;
36 }
37 cout<<x<<endl;
38 }
39
40 return 0;
41 }