#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, M, x;
    scanf("%d%d", &N, &M);
    if(M * 4 % N == 0){
        x = M * 4;
    }
    else{
        x = M * 4 + N;
    }
    printf("%d", x);
    return 0;
}