using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); Console.WriteLine(Cuts(input[0],input[1])); } static long Cuts(int width, int height) { if(width < height) { return Cuts(height,width); } else if(height == 1) { return width-1; } else { if(height % 2 != 0) { return Cuts(width, (int)Math.Ceiling(height / 2.0)) + Cuts(width, (int)Math.Floor(height / 2.0)) + 1; } else { return Cuts(width, height / 2)*2 + 1; } } } }