#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-14;
const int maxn = 100500;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, ta, tb;
  cin >> a >> ta >> b >> tb;
  int st = 0, ed;
  char c;
  cin >> c;
  st += (c - '0') * 10 * 60;
  cin >> c;
  st += (c - '0') * 60;
  cin >> c >> c;
  st += (c - '0') * 10;
  cin >> c;
  st += (c - '0');
  st -= 300;
  ed = st + ta;
  int cur = 0, ans = 0;
  while (cur < ed && cur < 19 * 60) {
    if (cur + tb > st) ans++;
    cur += b;
  }
  cout << ans << '\n';
  return 0;
}
