def solve(a,b,c): if a==c==1: return -1 if a==c: return 1+solve(a,b,c-1) if a>c: return solve(c,b,a) assert 1<=a