#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const int N = 200010;
const int INF = 1e8;
const long long MOD1 = 1073741824;
using namespace std;
int time_to_int(string s) {
  int timet = 0;
  int powd = 0;
  powd += (s[0] - '0') * 10 + (s[1] - '0');
  timet += powd * 60;
  powd = 0;
  powd += (s[3] - '0') * 10 + (s[4] - '0');
  timet += powd;
  return timet;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a, ta;
  int b, tb;
  cin >> a >> ta >> b >> tb;
  string time_out;
  cin >> time_out;
  int tt = time_to_int(time_out);
  int t = 300;
  int ans = 0;
  while (true) {
    if (t > 1439) break;
    if (t < tt + ta && t + tb > tt) ans++;
    t += b;
  }
  cout << ans;
  return 0;
}
