#include <bits/stdc++.h>
using namespace std;
int main() {
  long int N, X, a;
  cin >> X, N;
  a = X + N - X;
  while (N % X != 0) {
    N = N - X;
    a = a + N / X * 2 + 1;
  }
  a = a + N / X * 2 + 2;
}
