#include<bits/stdc++.h> using namespace std; int n,k,s,i; int main() { cin>>n>>k; while(s!=k){ i++; if(__gcd(i,n)==1){ s++; } } cout<<i; }