object Main{ def main(A:Array[String]){ val s = new java.util.Scanner(System.in) val t=s.next println(if(t.matches("13+"))t.length-1 else -1) } }