#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int a, ta, b, tb;
  int n, m;
  scanf("%d%d%d%d", &a, &ta, &b, &tb);
  scanf("%d:%d", &n, &m);
  int ts = n * 60 + m, t1 = 300;
  int tm = ts + ta;
  int tt = 24 * 60;
  int count = 0;
  while (t1 < tt) {
    if (t1 + tb > ts && t1 < tm) count++;
    t1 += b;
  }
  printf("%d\n", count);
  return 0;
}
