#include<iostream> //WA
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
struct Node
{
int st,ed;
bool operator<(const Node& other)const
{
if(st==other.st)
return ed<other.ed;
else
return st<other.st;
}
}node[200];
int vis[50];
int main()
{
int t=1,p,s,e;
while(cin>>p,p)
{
for(int i=0;i<p;++i)
{
cin>>s>>e;
node[i].st=8+(s-8)*2;
node[i].ed=8+(e-8)*2;
}
sort(node,node+p);
memset(vis,0,sizeof(vis));
int res=0;
for(int i=0;i<p;++i)
{
for(int j=node[i].st;j<node[i].ed;++j)
if(vis[j]==0)
{
vis[j]=1;
res++;
break;
}
}
printf("On day %d Emma can attend as many as %d parties.\n",t++,res);
}
return 0;
}
/*
选择策略有问题,比如输入:
5
8 11
8 11
8 11
8 11
9 10
答案应该是5而不是4
*/