fun main(args: Array) { val N = readLine()!! println(ushi(N)) } inline fun ushi(N: String): Int { if (N[0] != '1') return -1 val i = N.count {it == '3'} return if (i == N.length - 1) i else -1 }