var n:word;begin read(n);n:=n*2;repeat n:=(n*3+1)div(6-1and n*5);writeln(n)until n<2end.