#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, t, ans, now;
string x;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> ta >> b >> tb;
  cin >> x;
  t = ((x[0] - '0') * 10 + x[1] - '0') * 60 + ((x[3] - '0') * 10 + x[4] - '0');
  for (int nt = 300; nt < t + ta; nt++) {
    if (nt <= 1439 && (nt - 300) % b == 0) {
      now++;
      if (nt > t) {
        ans++;
      }
    }
    if ((nt - 300 - tb) % b == 0 && nt >= 300 + tb) now--;
    if (nt == t) ans += now;
  }
  cout << ans << endl;
  return 0;
}
