for x1 in range(62, 10009): x=x1 a = x - 61 b = 3*x - 138 while a != b: if a > b: a -= b else: b -= a if a == 45: print(x1) break