/* 
   AOJ 2013
   Osaki
   2015/9/8
*/

#include<stdio.h>
#include<stdlib.h>

#define MAX_TIMETABLE 10000

struct timetable
{
  int start, end;
};


struct timetable time_table[MAX_TIMETABLE];
int train[MAX_TIMETABLE];


struct node
{
  int val;
  struct node *link;
};

struct node *head = NULL;

void init()
{
  head = NULL;
}

int empty()
{
  return head == NULL;
}

int get()
{
  int get_val = head->val;
  struct node *get_node = head->link;
  free(head);
  head = get_node;
  return get_val;
}

int peak()
{
  return head->val;
}

void insert(int new_val)
{
  struct node *new_node = malloc(sizeof(*new_node)), *next = head, *prev = head;

  new_node->val = new_val;

  if(head == NULL)
    {
      head = new_node;
      new_node->link = NULL;
    }
  else
    {
      while(next != NULL && next->val <= new_val)
	{
	  prev = next;
	  next = next->link;
	}
      if(head == next)
	{
	  if(head->val > new_val)
	    {
	      new_node->link = head;
	      head = new_node;
	    }
	  else
	    {
	      new_node->link = NULL;
	      head->link = new_node;
	    }
	}
      else
	{
	  prev->link = new_node;
	  new_node->link = next;	  
	}
    }
}

void traverse()
{
  struct node *pres;
  for(pres = head; pres != NULL; pres = pres->link)
    {
      printf("%6d", pres->val);
    }
  printf("\n");
}


int count_enable_train(int start_t)
{
  struct node *pres;
  int count = 0;
  for(pres = head; pres != NULL && pres->val >= start_t; pres = pres->link)
    {
      count++;
    }
  return count - 1;
}

int ans_f(int timetable_n)
{
  int i, train_counter = 0, enable_train = 0;

  init();

  for(i = 0; i < timetable_n; i++)
    {
      insert(time_table[i].end);

      if(time_table[i].start >= peak())
	{
	  /* have some enable trains */
	  get();		/* use the peak train */
	}
      else
	{
	  /* have no enable train */
	  train_counter++;	/* add an one train */
	}
    }
  return train_counter;
}

int comp(const void *a, const void *b)
{
  struct timetable x = *(struct timetable*)a, y = *(struct timetable*)b;
  if(x.start < y.start)
    {
      return -1;
    }
  else
    {
      return 1;
    }
}

int main(void)
{
  int timetable_n, i, start_h, start_m, start_s, end_h, end_m, end_s;
  while(1)
    {
      scanf("%d", &timetable_n);
      if(timetable_n == 0)
	{
	  break;
	}
      for(i = 0; i < timetable_n; i++)
	{
	  scanf("%d:%d:%d %d:%d:%d", &start_h, &start_m, &start_s, &end_h, &end_m, &end_s);
	  time_table[i].start = start_h * 10000 + start_m * 100 + start_s;
	  time_table[i].end = end_h * 10000 + end_m * 100 + end_s;
	}
      qsort(time_table, timetable_n, sizeof(struct timetable), comp);
      printf("%d\n", ans_f(timetable_n));
    }
  return 0;
}