#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  float k;
  k = n * (0.5);
  if (x < k) {
    k = n + 7 * x / 2;
    cout << k;
  }
  if (x == k) {
    k = 3 * x;
  }
  if (x > k) {
    k = 10 * (n - x);
    cout << k;
  }
  return 0;
}
