#include <bits/stdc++.h>
using namespace std;
char s[10];
int main() {
  ios::sync_with_stdio(false);
  int a, ta, b, tb, T;
  cin >> a >> ta >> b >> tb;
  cin >> s;
  T = (s[0] - '0') * 10 * 60 + (s[1] - '0' - 5) * 60 + (s[3] - '0') * 10 +
      s[4] - '0';
  int l, r;
  if (T - tb < 0) {
    l = 0;
  } else
    l = b * (1 + (T - tb) / b);
  r = min(59 + 18 * 60, b * ((b - 1 + T + ta) / b - 1));
  if (l <= r)
    cout << 1 + (r - l) / b;
  else
    cout << 0;
  return 0;
}
