using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { var c = NList; var ans = c[0] + c[1]; for (var i = 1; i <= Math.Min(c[0], c[1]); ++i) { ans = Math.Min(ans, Math.Abs(c[0] + c[1] - 4 * i)); } WriteLine(ans); } }