#include <stdio.h>
int main()
{
int x, n, m, y, other, sum;
scanf("%d %d",&x, &n);
other = 7 - x + 1;
m = (n - other) / 7;
n = (n - other) % 7;
if (x<=6)
{
if (y<=5)
sum = n-2-2*m;
if (y==6)
sum = n-3-2*m;
if (y==7)
sum = n-4-2*m;
}
else
{
if (y<=5)
sum = n-1-2*m;
if (y==6)
sum = n-2-2*m;
if (y==7)
sum = n-3-2*m;
}
printf("%d", sum*250);
return 0;
}