#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta, b, tb, h, m, x1, y1;
  string dep;
  cin >> a >> ta >> b >> tb >> dep;
  h = atoi(dep.substr(0, 2).c_str());
  m = atoi(dep.substr(3, 2).c_str());
  x1 = h * 60 + m;
  y1 = x1 + ta;
  int cnt = 0;
  int x, y;
  for (int x2 = 5 * 60; x2 < 24 * 60; x2 += b) {
    int y2 = x2 + tb;
    x = max(x1, x2);
    y = min(y1, y2);
    if (x < y) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
