// yukicoder 333 (http://yukicoder.me/problems/935) #include #include int A, B; int main() { scanf( "%d%d", &A, &B ); printf( "%d\n", A>B?(2000000000-A)+(A-B-1):(A-1)+(B-A-1) ); return 0; }