using System;
namespace ConsoleApp6
{
internal class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
string[] str1 = str.Split(' ');
int x = int.Parse(str1[0]);
int n = int.Parse(str1[1]);
int n1 = n % 7;
int week = n / 7;
int day = x + n1;
if (x < 6)
{
if (day < 6) { Console.WriteLine((week * 5 + day + 1 - x) * 250); }
else if (day == 6) { Console.WriteLine((week * 5 + day - x) * 250); }
else if (day == 7) { Console.WriteLine((week * 5 + day - 1 - x) * 250); }
else { Console.WriteLine((week * 5 + day - 1 - x) * 250); }
}
else if (x == 6)
{
if (day == 6) { Console.WriteLine((week * 5 + day - x) * 250); }
else if (day == 7) { Console.WriteLine((week * 5 + day - 1 - x) * 250); }
else { Console.WriteLine((week * 5 + day - 1 - x) * 250); }
}
else
{
if (day == 7) { Console.WriteLine((week * 5 + day - x) * 250); }
else if (day == 13) { Console.WriteLine((week * 5 + day-1- x) * 250); }
else { Console.WriteLine((week * 5 + day - x) * 250); }
}
}
}
}