#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, ta, b, tb;
  cin >> a >> ta >> b >> tb;
  int h, m;
  char S;
  cin >> h >> S >> m;
  int s = h * 60 + m;
  int e = h * 60 + m + ta;
  int c = 0;
  for (int i = 5 * 60; i <= 23 * 60 + 59; i += b) {
    int s1 = i;
    int e1 = i + tb;
    if (max(s, s1) < min(e, e1)) c++;
  }
  cout << c << "\n";
  return 0;
}
