s = gets.chomp if s =~ /^13*$/ puts s.split("1")[1].length else puts "-1" end