#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, h, m;
int f(int r) {
  if (r <= 60 * 5) return 0;
  return (r - 60 * 5 - 1) / b + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char c;
  cin >> a >> ta >> b >> tb >> h >> c >> m;
  int s = 60 * h + m, e = s + ta;
  int l = s - tb, r = min(e, 24 * 60);
  cout << f(r) - f(l + 1) << '\n';
  return 0;
}
