try:
	while True:
		f=lambda l,r:r==x or l and f(l-1,[t%l for t in r])|f(l-1,r)
		x=input();l=len(x);print+f(l,range(l))
except:
	pass