def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython ''' ''' def Dec_to_N(num, base): if num >= base: yield from Dec_to_N(num // base, base) yield num % base def N_to_Dec(digits, base): num = 0 for digit in digits: num = num * base + digit return num N = int(input()) for i in range(2,10**5): ls = list(Dec_to_N(N,i)) f = True n = ls[0] for j in range(len(ls)): if ls[j] != n: f = False break if f: print(i) exit() if __name__ == '__main__': main()