#include<iostream> #include<cstdio> using namespace std; int main() { long long x,n,t,d; cin>>x>>n; d=n-(7-x); if(x==6||x==7) t=d/7*5*250+d%7*250; t=d/7*5*250+d%7*250+(7-2-x)*250; cout<<t; return 0; }