#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return f * x;
}
int main() {
  long long a = read(), b = read();
  if (a == 2 * b) {
    printf("%lld\n", 3ll * a / 2ll);
    return 0;
  }
  printf("%lld\n", (a - 1ll) * 3ll);
  return 0;
}
