#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main(){
	int n, T;
	cin>>n>>T;
	int a, b;
	string t1, t2, n1, n2;
	vector<pair<string, int> > ans;
	cin>>t1>>n1;
	//cout<<n-1<<endl;
	//cout<<T<<endl;
	rep(i, n-1){
		cin>>t1>>n1>>t2>>n2;
		//if(n2!=n1) continue;
		a = b = 0;
		a = (t1[0]*10+t1[1])*60+t1[3]*10+t1[4];
		b = (t2[0]*10+t2[1])*60+t2[3]*10+t2[4];
		//cout<<(b-a >= T)<<n1<<endl;
		if(b-a >= T){
			ans.pb(mp(n1, b-a));
		}
	}
	cin>>t1>>n1;
	cout<<ans.size()<<endl;
	rep(i, ans.size()){
		cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	}
}