#include <bits/stdc++.h>
int main(void) {
  int a, at;
  int b, bt;
  int start, i;
  scanf("%d %d %d %d", &a, &at, &b, &bt);
  int num1, num2, result = 0;
  scanf("%d:%d", &num1, &num2);
  start = num1 * 60 + num2;
  for (i = 300; i < 24 * 60; i += b) {
    if (start == i + bt || start + at == i) continue;
    if (i <= start + at && start <= i + bt) {
      result++;
    }
  }
  printf("%d\n", result);
  return 0;
}
