#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std ;
int n ;
struct node
{
int p,t ;
}a[2020];
bool operator<(const node &x,const node &y)
{
if(x.p==y.p) return x.t<y.t ;
else x.p<=y.p ;
}
const int N=2010 ;
int main()
{
scanf("%d",&n) ;
memset(a,0,sizeof(a)) ;
for(int i=1;i<=n;i++)
{
scanf("%d %d",&a[i].p,&a[i].t) ;
}
int ans=0 ;
for(int i=1;i<=6;i++)
{
if(a[i].p==0) break ;
else
{
for(int j=2;j<=sizeof(a[i]);j++)
{
if(a[j].t-a[j-1].t>=60) ans++ ;
}
}
}
cout<<ans<<endl ;
return 0 ;
}