using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using static System.Math; namespace SortItems { class Program { static void Main(string[] args) { var n = Console.ReadLine().Split().Select(int.Parse).ToArray(); var a = n[0]; var b = n[1]; if (a < b) { Console.WriteLine(b - 2); } else { Console.WriteLine(2000000000 - b - 1); } } } }