#include <bits/stdc++.h>
int min(int a, int b) { return a <= b ? a : b; }
int main() {
  int a, ta, b, tb;
  int time_h, time_m;
  scanf("%d %d", &a, &ta);
  scanf("%d %d", &b, &tb);
  scanf("%d:%d", &time_h, &time_m);
  int m = (time_h - 5) * 60 + time_m;
  int bus_b = 0;
  for (int i = 0; i < (24 - 5) * 60; ++i) {
    if (i >= tb && (i - tb) % b == 0) {
      --bus_b;
    }
    if (i == m) {
      for (int j = i; j < min((24 - 5) * 60, m + ta); ++j) {
        if (j % b == 0) {
          ++bus_b;
        }
      }
      break;
    }
    if (i % b == 0) {
      ++bus_b;
    }
  }
  printf("%d\n", bus_b);
  return 0;
}
