#include <bits/stdc++.h>
using namespace std;
int main() {
  int t1, k1, t2, k2;
  int a, b;
  scanf("%d%d%d%d", &t1, &k1, &t2, &k2);
  scanf("%d:%d", &a, &b);
  int p1 = a * 60 + b;
  int p2 = p1 + k1;
  int i;
  int ans = 0;
  for (i = 300; i < 1440; i = i + t2) {
    if (i >= p2) break;
    if (i + k2 <= p1) continue;
    ans++;
  }
  printf("%d\n", ans);
}
