import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void main() { int x, y; readV(x, y); if (x != 0 && y != 0 && x.abs != y.abs) { writeln(-1); return; } auto a = [[5, 6, 7], [4, 1, 1], [3, 2, 1]]; auto d = [1, 0, 2, 3, 1, 0, 2, 3]; writeln(d[a[y.sgn+1][x.sgn+1]]); } auto sgn(T)(T n) { return n > 0 ? 1 : n < 0 ? -1 : 0; }