#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll x, y, ans = 0;
  cin >> x >> y;

  if (x == 1) {
    ans += 300000;
  }

  else if (x == 2) {
    ans += 200000;
  }

  else if (x == 3) {
    ans += 100000;
  }

  if (y == 1) {
    ans += 300000;
  }

  else if (y == 2) {
    ans += 200000;
  }

  else if (y == 3) {
    ans += 100000;
  }

  if (x == 1 && y == 1) {
    ans += 400000;
  }

  cout << ans << "\n";
}
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,m;
  cin>>n>>m;
  set<int> s1;
  rep(i,2,sqrt(m)+1){
    if(m%i==0) s1.insert(i);
    if(m%i==0 && m%(m/i)==0) s1.insert(m/i);
  }
  s1.insert(m);
  s1.insert(1);
  for(auto i:s1){
    if(i>=n){
      cout<<m/i<<endl;
      return;
    }
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}
