fun main() { println(Regex("^13+$").find(readLine()!!)?.value?.length ?: -1) }