x = input() if x == 1: print(0) else: c = p t = True for i in x: if i == 3: c = c + 1 else: t = False print(-1) break if t: print(c)