#include <bits/stdc++.h>
using namespace std;
int main() {
  int Usless, Ta, b, Tb, Count = 0;
  scanf("%d%d%d%d", &Usless, &Ta, &b, &Tb);
  int h, m;
  scanf("%d:%d", &h, &m);
  int S = 60 * h + m;
  int E = S + Ta;
  for (int i = 0;; i++) {
    int D = 5 * 60 + i * b;
    int A = D + Tb;
    if (D >= 24 * 60) break;
    if (A > S && D < E) Count++;
  }
  printf("%d\n", Count);
}
