#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, hh, mm, res1, res2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> ta >> b >> tb;
  char tmp;
  cin >> hh >> tmp >> mm;
  hh -= 5;
  mm += hh * 60;
  if (mm - tb >= 0) res1 = (mm - tb) / b + 1;
  mm += ta;
  mm = min(mm, (24 - 5) * 60);
  mm--;
  res2 = mm / b + 1;
  cout << res2 - res1 << endl;
}
