#include <bits/stdc++.h>
using namespace std;
int fin;
int main() {
  int a, a1, b, b1, hour, minu;
  char c;
  cin >> a >> a1 >> b >> b1;
  cin >> hour >> c >> minu;
  int star = hour * 60 + minu;
  int enda = star + a1;
  for (int i = 60 * 5; i < 24 * 60; i += b) {
    if (i + b1 > star && i < enda) fin++;
  }
  cout << fin << endl;
  return 0;
}
