#include <bits/stdc++.h>
int main() {
  int a, ta, b, tb;
  scanf("%d%d%d%d", &a, &ta, &b, &tb);
  int h, m;
  scanf("%d:%d", &h, &m);
  m += h * 60;
  int ans = 0;
  int l = m - tb + 1, r = m + ta - 1;
  for (int i = 5 * 60; i <= 23 * 60 + 59; i += b) {
    ans += (l <= i && i <= r);
  }
  printf("%d\n", ans);
  return 0;
}
