#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, h, m, l, r, res, bad = 23 * 60 + 59;
int main() {
  cin >> a >> ta >> b >> tb;
  scanf("%d:%d", &h, &m);
  l = h * 60 + m;
  r = h * 60 + m + ta;
  int start = 5 * 60;
  while (start < r && start <= bad) {
    if ((start + tb) > l) res++;
    start += b;
  }
  cout << res;
  return 0;
}
