#include <bits/stdc++.h>
using namespace std;
int ans, t, m, n, a, b, ta, tb;
char s[10];
void pdo() {
  int x = t - tb + 1, y = t + ta - 1;
  x = max(300, x);
  y = min(1439, y);
  for (int i = 0; i < 1440; i++) {
    if ((i * b + 300) >= x && (i * b + 300) <= y) ans++;
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d %d %d %d", &a, &ta, &b, &tb);
  scanf("%s", s);
  int t1 = ((s[0] - '0') * 10 + (s[1] - '0')) * 60;
  int t2 = (s[3] - '0') * 10 + (s[4] - '0');
  t = t1 + t2;
  pdo();
}
