#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta, b, tb, h, m, flag, sum, st, ed, st2, ed2;
  scanf("%d%d", &a, &ta);
  scanf("%d%d", &b, &tb);
  scanf("%2d:%2d", &h, &m);
  st = h * 60 + m;
  ed = st + ta;
  st2 = 300;
  ed2 = st2 + tb;
  sum = flag = 0;
  while (1) {
    if (!(ed <= st2 || ed2 <= st)) {
      sum++;
      flag = 1;
    } else if (flag)
      break;
    st2 += b;
    ed2 = st2 + tb;
    if (st2 > 1440 - 1) break;
  }
  printf("%d\n", sum);
  return 0;
}
