#include <stdio.h>
int main(){
int s = 250;
int x, n, distance = 0;
scanf("%d %d",&x,&n);
while(n--){ // 只要n>0就一直走此循环
if(x<=5) // 如果x(周x)非双休日,则距离增加250
distance += s;
x = x%7+1; // 让x%7+1循环增加
}
printf("%d",distance);
return 0;
}