#include <bits/stdc++.h>
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
using namespace std;
void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  file();
  int a, ta, b, tb, m, h, ans = 0, m1, m2, m3, x, y, xx, yy, c = 0;
  char cc;
  cin >> a >> ta >> b >> tb >> h >> cc >> m;
  x = h * 60 + m;
  y = x + ta;
  vector<int> st;
  for (int i = 5 * 60; i < 24 * 60; i += b)
    for (int k = i; k <= i + tb; k++)
      if (k >= x && k <= y && i != y && i + tb != x) {
        c++;
        break;
      }
  cout << c << '\n';
}
