import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int p = in.nextInt(); int d = in.nextInt(); int m = in.nextInt(); int s = in.nextInt(); if(s
s) break; else { //System.out.println(p+" "+s ); c++; } } System.out.println(c); } } }