#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, m, b, n;
  cin >> a >> m >> b >> n;
  string s;
  cin >> s;
  int time = (s[0] - '0') * 10 + s[1] - '0';
  time *= 60;
  time += (s[3] - '0') * 10 + s[4] - '0';
  int start = time;
  int en = min(start + m, 1440);
  int bstart = 300;
  int re = 0;
  while (bstart <= 1439) {
    if ((bstart > start && bstart < en) ||
        (bstart + n > start && bstart < en)) {
      re++;
    }
    bstart += b;
  }
  cout << re << endl;
  return 0;
}
