import
java.io.*;
class
GFG
{
static
int
convert(String str)
{
str = str.substring(
0
,
2
) + str.substring(
3
);
int
h1 = (
int
)str.charAt(
1
) -
'0'
;
int
h2 = (
int
)str.charAt(
0
) -
'0'
;
int
hh = (h2 *
10
+ h1 %
10
);
int
time =
0
;
if
(str.charAt(
5
) ==
'A'
) {
if
(hh ==
12
)
time += Integer.parseInt(
str.substring(
2
,
4
));
else
{
time += Integer.parseInt(
str.substring(
0
,
2
));
}
}
else
{
if
(hh ==
12
) {
time += Integer.parseInt(
str.substring(
0
,
4
));
}
else
{
time += Integer.parseInt(
str.substring(
0
,
4
));
time +=
1200
;
}
}
return
time;
}
static
int
countOverlap(String arr[][],
int
n, String p)
{
int
ans =
0
;
int
M = convert(p);
for
(
int
i =
0
; i < n; i++)
{
int
L = convert(arr[i][
0
]);
int
R = convert(arr[i][
1
]);
if
((L <= M && M <= R) || (M >= R && M <= L))
ans++;
}
return
ans;
}
public
static
void
main(String[] args)
{
String[][] arr
=
new
String[][] { {
"12:00:AM"
,
"11:55:PM"
},
{
"12:01:AM"
,
"11:50:AM"
},
{
"12:30:AM"
,
"12:00:PM"
},
{
"11:57:AM"
,
"11:59:PM"
} };
String P =
"12:01:PM"
;
int
N = arr.length;
System.out.println(countOverlap(arr, N, P));
}
}