#include <stdio.h>
int main()
{
long long n,t,d,s;
int x;
scanf("%d %lld",&x,&n);
if(x<=6)
{
if(n<=6-x)
t=n;
else if(n>6-x&&n<=8-x)
t=6-x;
else if(n>8-x)
{
d=(n-8+x)/7;
if((n-8+x)%7==6)
t=n-2*d-2-1;
else
t=n-2*d-2;
}
}
if(x==7)
{
d=n/7;
if(n%7==6)
t=n-2*d-1;
else
t=n-2*d;
}
s=250*t;
printf("%lld",s);
return 0;
}