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