import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); String[] a = in.nextLine().split(","); int one, sum, jl, qs, zd, q, w; int xs, fen, xs2, fen2; one = Integer.parseInt(a[0]); if (one < 3 || !isValidDate(a[1]) || !isValidDate(a[2])) { System.out.println("incorrect data"); } else { sum = one * 15; xs = Integer.parseInt(a[1].substring(11, 13)); fen = Integer.parseInt(a[1].substring(14, 16)); xs2 = Integer.parseInt(a[2].substring(11, 13)); fen2 = Integer.parseInt(a[2].substring(14, 16)); jl = (xs2 - xs) * 60 + fen2 - fen; qs = jl / sum + 1; zd = jl % sum; int which15 = (zd % 15==0)?zd/15:(zd/15+1) ; q = (which15 == one) ? 1 : (which15 + 1); w = (which15 == one) ? q : (zd % 15 == 0) ? q : (q + 1); System.out.println(qs + ";" + q + "-" + w); } } public static boolean isValidDate(String str) { boolean convertSuccess = true; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { format.setLenient(false); format.parse(str); } catch (ParseException e) { convertSuccess = false; } return convertSuccess; } }