{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tMohammad has recently visited \u003cst1:country-region w:st\u003d\"on\"\u003e\u003cst1:place w:st\u003d\"on\"\u003eSwitzerland\u003c/st1:place\u003e\u003c/st1:country-region\u003e. As he loves his friends very much, he decided to buy some chocolate for them, but as this fine chocolate is very expensive(You know Mohammad is a little BIT stingy!), he could only afford buying one chocolate, albeit a very big one (part of it can be seen in figure 1) for all of them as a souvenir. Now, he wants to give each of his friends exactly one part of this chocolate and as he believes all human beings are equal (!), he wants to split it into equal parts.\u003c/p\u003e\r\n\u003cdiv\u003e\r\n\t\u003cp\u003e\r\n\t\tThe chocolate is an \u003c!--[if gte vml 1]\u003e\u003cv:shapetype\r\n id\u003d\"_x0000_t75\" coordsize\u003d\"21600,21600\" o:spt\u003d\"75\" o:preferrelative\u003d\"t\"\r\n path\u003d\"m@4@5l@4@11@9@11@9@5xe\" filled\u003d\"f\" stroked\u003d\"f\"\u003e\r\n \u003cv:stroke joinstyle\u003d\"miter\"/\u003e\r\n \u003cv:formulas\u003e\r\n \u003cv:f eqn\u003d\"if lineDrawn pixelLineWidth 0\"/\u003e\r\n \u003cv:f eqn\u003d\"sum @0 1 0\"/\u003e\r\n \u003cv:f eqn\u003d\"sum 0 0 @1\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @2 1 2\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @3 21600 pixelWidth\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @3 21600 pixelHeight\"/\u003e\r\n \u003cv:f eqn\u003d\"sum @0 0 1\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @6 1 2\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @7 21600 pixelWidth\"/\u003e\r\n \u003cv:f eqn\u003d\"sum @8 21600 0\"/\u003e\r\n \u003cv:f eqn\u003d\"prod @7 21600 pixelHeight\"/\u003e\r\n \u003cv:f eqn\u003d\"sum @10 21600 0\"/\u003e\r\n \u003c/v:formulas\u003e\r\n \u003cv:path o:extrusionok\u003d\"f\" gradientshapeok\u003d\"t\" o:connecttype\u003d\"rect\"/\u003e\r\n \u003co:lock v:ext\u003d\"edit\" aspectratio\u003d\"t\"/\u003e\r\n\u003c/v:shapetype\u003e\u003cv:shape id\u003d\"_x0000_i1025\" type\u003d\"#_x0000_t75\" style\u003d\u0027width:30pt;\r\n height:12pt\u0027 o:ole\u003d\"\"\u003e\r\n \u003cv:imagedata src\u003d\"http://uva.onlinejudge.org/external/109/images/p6_files/image001.wmz\" o:title\u003d\"\"/\u003e\r\n\u003c/v:shape\u003e\u003c![endif]--\u003e\u003c!--[if !vml]--\u003e\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970a.gif\" v:shapes\u003d\"_x0000_i1025\" /\u003e\u003c!--[endif]--\u003e\u003c!--[if gte mso 9]\u003e\u003cxml\u003e\r\n \u003co:OLEObject Type\u003d\"Embed\" ProgID\u003d\"Equation.3\" ShapeID\u003d\"_x0000_i1025\"\r\n DrawAspect\u003d\"Content\" ObjectID\u003d\"_1192912430\"\u003e\r\n \u003c/o:OLEObject\u003e\r\n\u003c/xml\u003e\u003c![endif]--\u003e\u0026nbsp;rectangle constructed from \u003c!--[if gte vml 1]\u003e\u003cv:shape id\u003d\"_x0000_i1026\" type\u003d\"#_x0000_t75\"\r\n style\u003d\u0027width:30pt;height:12pt\u0027 o:ole\u003d\"\"\u003e\r\n \u003cv:imagedata src\u003d\"http://uva.onlinejudge.org/external/109/images/p6_files/image003.wmz\" o:title\u003d\"\"/\u003e\r\n\u003c/v:shape\u003e\u003c![endif]--\u003e\u003c!--[if !vml]--\u003e\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970a.gif\" v:shapes\u003d\"_x0000_i1026\" /\u003e\u003c!--[endif]--\u003e\u003c!--[if gte mso 9]\u003e\u003cxml\u003e\r\n \u003co:OLEObject Type\u003d\"Embed\" ProgID\u003d\"Equation.3\" ShapeID\u003d\"_x0000_i1026\"\r\n DrawAspect\u003d\"Content\" ObjectID\u003d\"_1192912431\"\u003e\r\n \u003c/o:OLEObject\u003e\r\n\u003c/xml\u003e\u003c![endif]--\u003e\u0026nbsp;unit-sized squares. You can assume that Mohammad has also \u003c!--[if gte vml 1]\u003e\u003cv:shape id\u003d\"_x0000_i1027\"\r\n type\u003d\"#_x0000_t75\" style\u003d\u0027width:30pt;height:12pt\u0027 o:ole\u003d\"\"\u003e\r\n \u003cv:imagedata src\u003d\"http://uva.onlinejudge.org/external/109/images/p6_files/image004.wmz\" o:title\u003d\"\"/\u003e\r\n\u003c/v:shape\u003e\u003c![endif]--\u003e\u003c!--[if !vml]--\u003e\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970a.gif\" v:shapes\u003d\"_x0000_i1027\" /\u003e\u003c!--[endif]--\u003e\u003c!--[if gte mso 9]\u003e\u003cxml\u003e\r\n \u003co:OLEObject Type\u003d\"Embed\" ProgID\u003d\"Equation.3\" ShapeID\u003d\"_x0000_i1027\"\r\n DrawAspect\u003d\"Content\" ObjectID\u003d\"_1192912432\"\u003e\r\n \u003c/o:OLEObject\u003e\r\n\u003c/xml\u003e\u003c![endif]--\u003e\u0026nbsp;friends waiting to receive their piece of chocolate.\u003co:p\u003e\u003c/o:p\u003e\u003c/p\u003e\r\n\t\u003cp\u003e\r\n\t\tTo split the chocolate, Mohammad can cut it in vertical or horizontal direction (through the lines that separate the squares). Then, he should do the same with each part separately until he reaches \u003c!--[if gte vml 1]\u003e\u003cv:shape id\u003d\"_x0000_i1028\"\r\n type\u003d\"#_x0000_t75\" style\u003d\u0027width:30pt;height:12pt\u0027 o:ole\u003d\"\"\u003e\r\n \u003cv:imagedata src\u003d\"http://uva.onlinejudge.org/external/109/images/p6_files/image005.wmz\" o:title\u003d\"\"/\u003e\r\n\u003c/v:shape\u003e\u003c![endif]--\u003e\u003c!--[if !vml]--\u003e\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970a.gif\" v:shapes\u003d\"_x0000_i1028\" /\u003e\u003c!--[endif]--\u003e\u003c!--[if gte mso 9]\u003e\u003cxml\u003e\r\n \u003co:OLEObject Type\u003d\"Embed\" ProgID\u003d\"Equation.3\" ShapeID\u003d\"_x0000_i1028\"\r\n DrawAspect\u003d\"Content\" ObjectID\u003d\"_1192912433\"\u003e\r\n \u003c/o:OLEObject\u003e\r\n\u003c/xml\u003e\u003c![endif]--\u003e\u0026nbsp;unit size pieces of chocolate. Unfortunately, because he is a little lazy, he wants to use the minimum number of cuts required to accomplish this task.\u003co:p\u003e\u003c/o:p\u003e\u003c/p\u003e\r\n\t\u003cp\u003e\r\n\t\tYour goal is to tell him the minimum number of cuts needed to split all of the chocolate squares apart.\u003co:p\u003e\u003c/o:p\u003e\u003c/p\u003e\r\n\t\u003cp\u003e\r\n\t\t\u003co:p\u003e\u0026nbsp;\u003c/o:p\u003e\u003c/p\u003e\r\n\t\u003cdiv style\u003d\"text-align: center;\"\u003e\r\n\t\t\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970d.jpg\" /\u003e\u003c/div\u003e\r\n\t\u003cp style\u003d\"text-align: center;\"\u003e\r\n\t\tFigure 1. Mohammad\u0026rsquo;s chocolate\u003c/p\u003e\r\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe input consists of several test cases. In each line of input, there are two\u0026nbsp;integers\u0026nbsp;\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970b.gif\" v:shapes\u003d\"_x0000_i1029\" /\u003e, the number of rows in the chocolate and\u0026nbsp;\u003cimg src\u003d\"http://uva.onlinejudge.org/external/109/p10970c.gif\" v:shapes\u003d\"_x0000_i1030\" /\u003e, the number of columns in the chocolate. The input should be processed until end of file is encountered.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tFor each line of input, your program should produce one line of output containing an integer indicating the minimum number of cuts needed to split the entire chocolate into unit size pieces.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n2 2\r\n1 1\r\n1 5\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n3\r\n0\r\n4\u003c/pre\u003e"}}]}