#KADOMATSU # coding: utf-8 s=[] s=map(int,raw_input().split()) A=int(s[0]) B=int(s[1]) if A>B: print 2*10**9-B-1 else: #A