#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
using namespace std;
int hh, mm;
int a, ta;
int b, tb;
int main() {
  scanf("%d %d", &a, &ta);
  scanf("%d%d", &b, &tb);
  scanf("%d:%d", &hh, &mm);
  int Base = hh * 60 + mm;
  int i = 5 * 60;
  int ans = 0;
  while (i < 24 * 60) {
    if (i < Base && i + tb > Base) ans++;
    if (i >= Base && i < Base + ta) ans++;
    i += b;
  }
  cout << ans;
}
