N = input() if N[0] == '1' and set(N[1:]) == {'3'}: print(N.count('3')) else: print(-1)