
#include <stdio.h>

int main()
{
    int N, X;
    scanf("%d", &N);
    scanf("%d", &X);
    
    if(N % 2 == 0) {
        //even
        int n = N / 2;
        printf("%d", 3 * n + abs(X - n) * 3);
    } else {
        //odd;
        int n = N / 2;
        printf("%d", n * 6);
    }
    
    return 0;
}
