#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
void fast_in_out() {
  std::ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
}
void pause() {}
int dx[] = {0, 0, -1, -1, -1, 1, 1, 1};
int dy[] = {-1, 1, 0, 1, -1, -1, 0, 1};
int main() {
  fast_in_out();
  int h, m;
  int t1, f1;
  int t2, f2;
  char ch;
  cin >> f1 >> t1 >> f2 >> t2 >> h >> ch >> m;
  int time = 60 * h + m, ans = 0;
  for (int i = 5 * 60; i < 24 * 60; i += f2) {
    if (i + t2 > time && i < time + t1) ans++;
  }
  cout << ans << '\n';
  pause();
  return 0;
}
