
#include <iostream>
using namespace std;

const int MAX=100;

int Start[MAX], End[MAX], p, Parties[48];

void PrintParties(){
  for(int i=0;i<p;i++)
    cout<<Start[i]<<' '<<End[i]<<endl;
  for(int i=16;i<48;i++) cout<<Parties[i]<<' ';
  cout <<endl;
}

int SortOnEnd(){
   int j, x, y;
   for(int i=1;i<p;i++){
     x = End[i];  y=Start[i];
     j=i-1;
     while(j>-1 && End[j]>x){
       End[j+1] = End[j];
       Start[j+1] = Start[j];
       j--;
     }
     End[j+1] = x; Start[j+1] = y;
   }
}

int SortOnStart(){
   int j, x, y;
   for(int i=1;i<p;i++){
     y = End[i];  x=Start[i];
     j=i-1;
     while(j>-1 && Start[j]>x){
       End[j+1] = End[j];
       Start[j+1] = Start[j];
       j--;
     }
     End[j+1] = y; Start[j+1] = x;
   }
}

void GetParties(){
  int s,e;
  for(int i=0;i<p;i++){
    cin>>s>>e;
    End[i]=2*e;  Start[i]=2*s;
  }
}

int CountParties(){
  for(int i=0;i<48;i++) Parties[i]=0;

  for(int i=0;i<p;i++) {      //now see which parties can be used
//cout<<"party "<<i<<" "<<Start[i]<<" to "<<End[i]<<endl;
    //see if can attend party i - go as early as possible
    //check all times - pick earliest
    for(int j=Start[i]; j<End[i]; j++)
      if(Parties[j]==0){
//cout<<" attend at time "<<j<<endl;
        Parties[j]=1;
        j=MAX;
      }
  }

  int Count=0;
  for(int i=0;i<48;i++)
    if(Parties[i]==1) Count++;

  return Count;
}

int main(){
  int c, caseno=1;

  cin>>p;
  while(p>0){
    GetParties();
    SortOnStart();
    SortOnEnd();

    c = CountParties();

    cout<<"On day "<<caseno++<<" Emma can attend as many as "<<c<<" parties."<<endl;

    cin>>p;
  }
 return 0;
}
