#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta;
  cin >> a >> ta;
  int b, tb, h = 0, m = 0, num;
  int totmin;
  cin >> b >> tb;
  string s;
  cin >> s;
  for (int i = 0; i < 2; i++) {
    h = h * 10 + (s[i] - '0');
  }
  for (int i = 3; i < 5; i++) {
    m = m * 10 + (s[i] - '0');
  }
  totmin = h * 60 + m;
  int counter = 0;
  for (int i = 300; i <= 1439; i += b) {
    if ((i < totmin && i + tb > totmin) || (i >= totmin && i < totmin + ta))
      counter++;
  }
  cout << counter;
}
