#include <bits/stdc++.h>
int main() {
  int tmin = 05 * 60 + 00;
  int tmax = 23 * 60 + 59;
  int a, ta;
  int b, tb;
  int t, th, tm;
  scanf("%d %d", &a, &ta);
  scanf("%d %d", &b, &tb);
  scanf("%d:%d", &th, &tm);
  t = th * 60 + tm;
  int tf = t - tb;
  int tt = t + ta;
  if (tf < tmin)
    tf = tmin;
  else
    tf++;
  if (tt > tmax)
    tt = tmax;
  else
    tt--;
  tf -= tmin;
  tt -= tmin;
  int c = 0;
  for (int tc = tf; tc <= tt; tc++) {
    if (tc % b == 0) c++;
  }
  printf("%d", c);
  return 0;
}
