def main(): number = input() for num in number[1:]: if num != "3": number = "1" break if number == "1" or number[0] != "1": print(-1) else: print(len(str(number))-1) if __name__ == "__main__": main()