import java.util.*;
class Task3
{
public static void main
(String[] args
) {
int m1,m2,h1,h2, rings = 0;
Scanner in
= new Scanner
(System.
in); h1 = in.nextInt();
m1 = in.nextInt();
h2 = in.nextInt();
m2 = in.nextInt();
in.close();
while (true)
{
if (m1 == 0)
rings += (h1==0 || h1==12)?12:h1%12;
if (m1 == 30)
rings += 1;
if (m1 == m2 && h1 == h2)
break;
m1 ++ ;
if (m1 > 60)
{
m1 = 0;
h1 ++ ;
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgVGFzazMKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpCgl7CgkJaW50IG0xLG0yLGgxLGgyLCByaW5ncyA9IDA7CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJaDEgPSBpbi5uZXh0SW50KCk7CgkJbTEgPSBpbi5uZXh0SW50KCk7CgkJaDIgPSBpbi5uZXh0SW50KCk7CgkJbTIgPSBpbi5uZXh0SW50KCk7CgkJaW4uY2xvc2UoKTsKCQkKCQl3aGlsZSAodHJ1ZSkKCQl7CgkJCWlmIChtMSA9PSAwKQoJCQkJcmluZ3MgKz0gKGgxPT0wIHx8IGgxPT0xMik/MTI6aDElMTI7CgkJCQoJCQlpZiAobTEgPT0gMzApCgkJCQlyaW5ncyArPSAxOwoJCQkKCQkJaWYgKG0xID09IG0yICYmIGgxID09IGgyKQoJCQkJYnJlYWs7CgkJCQoJCQltMSArKyA7CgkJCWlmIChtMSA+IDYwKQoJCQl7CgkJCQltMSA9IDA7CgkJCQloMSArKyA7CgkJCX0KCQl9CgkJU3lzdGVtLm91dC5wcmludGxuKHJpbmdzKTsKCX0KfQ==