#include <bits/stdc++.h>
using namespace std;
int main() {
  int fa, fb, ta, tb, s, e, h, m, x = 0, i, s1, e1;
  string st;
  char c;
  cin >> fa >> ta;
  cin >> fb >> tb;
  cin >> st;
  stringstream ss;
  ss << st;
  ss >> h >> c >> m;
  s = h * 60 + m;
  e = s + ta;
  e1 = min(s + ta, 1439);
  s1 = max(s - tb, 300);
  for (i = s1; i <= e1; i++) {
    if (((i >= s && i < e) || (i + tb > s)) && ((i - 300) % fb == 0) &&
        i != e) {
      x++;
    }
  }
  cout << x;
  return 0;
}
