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