#include<iostream>
#include<algorithm>
#include <cmath>
#include<iomanip>
using namespace std;
int main() {
int n, x, a, b;
cin >> x >> n;
a = n % 7;
b = n / 7;
if (x <= 5) {
if (a + x <= 6) {
cout << b * 5 * 250 + a * 250;
}
else if (a + x >= 8) {
cout << b * 5 * 250 + (a - 2) * 250;
}
else {
cout << b * 5 * 250 + (a - 1) * 250;
}
}
else if (x == 6) {
if (a >= 2) {
cout << b * 5 * 250 + (a - 2) * 250;
}
else {
cout << b * 5 * 250;
}
}
else {
cout << b * 5 * 250 + (a - 1) * 250;
}
return 0;
}