def main(): z = input() if len(z) > 1 and z == '1' + '3' * (len(z)-1): print(len(z)-1) else: print(-1) if __name__ == '__main__': main()