#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  int a, ta, b, tb;
  cin >> a >> ta;
  cin >> b >> tb;
  int h, m;
  scanf("%02d:%02d", &h, &m);
  int st = 5 * 60 + 0;
  int l = h * 60 + m, r = l + ta;
  int ans = 0;
  for (int i = st; i < 24 * 60; i += b) {
    int ll = i, rr = i + tb;
    if (max(l, ll) < min(r, rr)) ans++;
  }
  cout << ans << endl;
  return 0;
}
