#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T = clock();
  long long int a, ta, b, tb;
  cin >> a >> ta >> b >> tb;
  string s;
  cin >> s;
  long long int i = 5 * 60, lim = 23 * 60 + 59;
  long long int st = stoi(s.substr(0, 2)) * 60 + stoi(s.substr(3));
  long long int ed = st + ta;
  long long int ans = 0;
  while (i < ed && i <= lim) {
    if (i + tb > st) ans++;
    i += b;
  }
  cout << ans;
  cerr << "\n\nTIME: " << (long double)(clock() - T) / CLOCKS_PER_SEC
       << " sec\n";
  T = clock();
  return 0;
}
