import java.util.Scanner; public class Main { static public void main(String[]args) throws Exception { Scanner sc = new Scanner(System.in); String n = sc.next(); printAns(n); } static void printAns(String s) throws Exception { if( isValid(s) ) { int ans = s.length() -1; System.out.println(ans); } else { System.out.println(-1); } } static boolean isValid(String s) throws Exception { if(s.charAt(0) != '1') return false; if(!s.contains("3")) return false; for(int i=1; i