using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; class Program { static void Main() { var sc = new FastScanner(); var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); int A = sc.Int(),B = sc.Int(); for(int i = 1;i < 100001;i++) { if(i % A == B % i) { Console.WriteLine(i); break; } } Console.Out.Flush(); } static int LowerBound(List list, long value) { int left = 0, right = list.Count; while (left < right) { int mid = left + (right - left) / 2; if (list[mid] < value) left = mid + 1; else right = mid; } return left; } static int UpperBound(List list, long value) { int left = 0, right = list.Count; while (left < right) { int mid = left + (right - left) / 2; if (list[mid] <= value) left = mid + 1; else right = mid; } return left; } static void D(object o) { #if DEBUG Console.WriteLine(o); #endif } } class FastScanner { private readonly Stream _stream; private readonly byte[] _buffer = new byte[1024]; private int _ptr = 0; private int _buflen = 0; public FastScanner() { _stream = Console.OpenStandardInput(); } private bool HasNextByte() { if (_ptr < _buflen) return true; _ptr = 0; _buflen = _stream.Read(_buffer, 0, _buffer.Length); return _buflen > 0; } private byte ReadByte() => HasNextByte() ? _buffer[_ptr++] : (byte)0; private static bool IsPrintableChar(int c) => 33 <= c && c <= 126; private void SkipUnprintable() { while (HasNextByte() && !IsPrintableChar(_buffer[_ptr])) _ptr++; } public string Str() { SkipUnprintable(); var sb = new StringBuilder(); while (HasNextByte() && IsPrintableChar(_buffer[_ptr])) { sb.Append((char)ReadByte()); } return sb.ToString(); } public int Int() { long n = Long(); if (n < int.MinValue || n > int.MaxValue) throw new OverflowException(); return (int)n; } public long Long() { SkipUnprintable(); long n = 0; bool minus = false; byte b = ReadByte(); if (b == '-') { minus = true; b = ReadByte(); } if (b < '0' || '9' < b) throw new FormatException(); while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == (byte)0 || !IsPrintableChar(b)) return minus ? -n : n; else throw new FormatException(); b = ReadByte(); } } public double Double() => double.Parse(Str()); public int[] IntArr(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Int(); return a; } public long[] LongArr(int n) { var a = new long[n]; for (int i = 0; i < n; i++) a[i] = Long(); return a; } }