#include<bits/stdc++.h> using namespace std; int main() { int s,w; cin>>s>>w; if (s==1){ w=8*w+(w-1)*1; cout<<w; }else{ w=10*w+(w-1)*2; cout<<w; } }