s = input() if s[0] == '1' and set(list(s[1:])) == {'3'}: print(len(s)-1) else: print(-1)