传送门
画图找规律。。
//By Menteur_Hxy #include <cstdio> #define min(a,b) ((a)>(b)?(b):(a)) int main() { int n,k;scanf("%d %d",&n,&k); printf("%d",n==1?1:(min(k,n-k+1)<<1)); return 0; }