import sys try: def test(num,now,count):
        x=False  temp=[] for i in now: if i+count==num or i-count==num: print(count)
               x= True  break  else:
               temp.append(i-count)
               temp.append(i+count) if x: return  else:
            test(num,temp,count+1) while True:
        num = int(sys.stdin.readline().strip())
        test(num,[0],1) except: pass