#include <bits/stdc++.h>
using namespace std;
int a, ta;
int b, tb;
int h, m;
bool read() {
  if (!(cin >> a >> ta)) return false;
  assert(cin >> b >> tb);
  assert(scanf("%d:%d", &h, &m) == 2);
  return true;
}
void solve() {
  int x1 = h * 60 + m;
  int y1 = x1 + ta;
  int ans = 0;
  for (int x2 = 5 * 60 + 0; x2 < 24 * 60; x2 += b) {
    int y2 = x2 + tb;
    int x = max(x1, x2), y = min(y1, y2);
    if (x < y) ans++;
  }
  cout << ans << endl;
}
int main() {
  read();
  solve();
  return 0;
}
