#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta, b, i, j, tb, h, m, t;
  int d, ar;
  char ch[10];
  cin >> a >> ta >> b >> tb;
  cin >> ch;
  h = (ch[0] - '0') * 10 + ch[1] - '0';
  m = (ch[3] - '0') * 10 + ch[4] - '0';
  t = (h - 5) * 60 + m;
  j = 0;
  long long count = 0;
  for (i = 0; i < 1140; i += b) {
    d = i;
    ar = i + tb;
    if (i > t + ta) break;
    if (ar > t && d < t + ta) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
