#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167177216")
using namespace std;
const int MAX = 2147483647;
const int MAXN = 200100;
const long long MOD = 1000000000 + 7;
vector<long long> t(MAXN, -2000000000);
long long n, k, b, c;
vector<long long> tmp(MAXN);
pair<bool, long long> check(int val) {
  long long ans = 0;
  int idx = 0;
  bool inited = false;
  for (int i = 0; i < n; ++i) {
    if (t[i] > val) continue;
    if (!inited && (n - i) < k) return make_pair(false, 0);
    inited = true;
    long long need = val - t[i];
    long long cost;
    if (5 * c <= b) {
      cost = (long long)need * c;
    } else {
      cost = (need / (long long)5) * b + (need % (long long)5) * c;
    }
    tmp[idx++] = cost;
  }
  sort(tmp.begin(), tmp.begin() + idx);
  for (int i = 0; i < k; ++i) {
    ans += tmp[i];
  }
  return make_pair(true, ans);
}
int main(int argc, char* argv[]) {
  int a, ta, b, tb;
  cin >> a >> ta >> b >> tb;
  int sh, sm;
  char tmp;
  cin >> sh >> tmp >> sm;
  int t = sh * 60 + sm;
  int te = t + ta;
  int ans = 0;
  for (int i = 5 * 60; i <= 23 * 60 + 59; i += b) {
    int st = i;
    int et = i + tb;
    if (st < te && et > t) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
