#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Station {
    string name;
    int time;
    Station() {}
    Station(string name, int time) : name(name), time(time) {}
};

int main()
{
    int N, T;
    char a[55], b[55];
    int h1, d1, h2, d2;
    string s;
    vector<Station> st;

    cin >> N >> T;
    cin >> s >> s;
    for (int i = 0; i < N - 1; ++i) {
        scanf("%d:%d %s %d:%d %s", &h1, &d1, a, &h2, &d2, b);
        int time = (h2 * 60 + d2) - (h1 * 60 + d1);
        if (time >= T)
            st.push_back(Station(a, time));
    }
    cin >> s >> s;

    cout << st.size() << "\n";
    for (size_t i = 0; i < st.size(); ++i)
        cout << st[i].name << " " << st[i].time << "\n";

    return 0;
}