#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, a, ta, b, tb, s, t, ans;
int main() {
  scanf("%d%d", &a, &ta);
  scanf("%d%d", &b, &tb);
  scanf("%d:%d", &t, &s);
  s += (t - 5) * 60;
  t = s + ta;
  s = s - tb;
  for (i = 0; i < 19 * 60; i += b)
    if (s < i && i < t) ans++;
  printf("%d\n", ans);
}
