#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, j, k, m, h = 0;
  long long int t1, t2, k1, k2, a1, a2, f1, f2;
  cin >> f1 >> a1;
  cin >> f2 >> a2;
  k1 = 0;
  char d;
  string s;
  cin >> s;
  k1 = (s[0] - '0') * 10 + (s[1] - '0');
  k2 = (s[3] - '0') * 10 + (s[4] - '0');
  k1 = k1 * 60 + k2;
  k2 = k1 + a1;
  for (i = 300; i <= 23 * 60 + 59; i += f2) {
    t1 = i + a2;
    if (t1 > k1 && i < k2) h++;
  }
  cout << h;
  return 0;
}
