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