read *,n,m if (n.lt.m) then print '(i0)', (abs(n-m)-1) + (n-1) else print '(i0)', 2*10**9-m-1 end if end program