#include <bits/stdc++.h>
int main() {
  uint32_t N, X;
  uint32_t th;
  uint32_t ans;
  scanf("%u %u", &N, &X);
  if (2 * X < N) {
    ans = 7 * X / 2 + N;
  } else if (2 * X == N) {
    ans = 3 * X;
  } else {
    ans = 6 * N - 5 * X;
  }
  printf("%u\n", ans);
}
