var a,b,c,d,x1,y1,x2,y2 : integer; begin assign(input, 'input.txt'); assign(output,'output.txt'); reset(input); rewrite(output); readln(x1,y1); if (x1 = y1) and ((x1 <> 1) or (y1 <> 1)) then writeln(2) else if (x1 <> 1) or (y1 <> 1) then writeln(1) else writeln(0) end.