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