#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
} zz[1000];
int main() {
  int a, ta, b, tb, hh, mm;
  scanf("%d%d%d%d", &a, &ta, &b, &tb);
  scanf("%d:%d", &hh, &mm);
  int num = 0;
  int st = 5 * 60;
  int ed = 23 * 60 + 59;
  while (st <= ed) {
    zz[num].l = st;
    zz[num].r = zz[num].l + tb;
    st += b;
    num++;
  }
  int a_st = hh * 60 + mm;
  int a_ed = a_st + ta;
  int ans = 0;
  for (int i = 0; i < num; i++) {
    if (a_st < zz[i].r && zz[i].l < a_ed) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
