#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta, b, tb;
  scanf("%d%d", &a, &ta);
  scanf("%d%d", &b, &tb);
  int h, m;
  scanf("%d:%d", &h, &m);
  int t0 = (h - 5) * 60 + m;
  int t1 = max(t0 - tb, 0);
  int t2 = min(t0 + ta - 1, 19 * 60 - 1);
  int ans = t2 / b - t1 / b;
  if (t0 - tb < 0) ++ans;
  printf("%d\n", ans);
  return 0;
}
