package main import ( "fmt" "strings" ) func main() { var n string fmt.Scan(&n) if len(n) == 1 || n[0] != '1' || strings.Count(n, "3") != len(n)-1 { fmt.Println("-1") } else { fmt.Println(strings.Count(n, "3")) } }