a,b=gets.split.map &:to_i p a>b ?2e9.to_i-b-1:b-2