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

#define N 10000
#define INT(X) \
  ( *( (const int *)(X) ) )

int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int lv[ N ], ar[ N ];
    int res = 0;
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      int h, m, s;

      scanf ( " %d:%d:%d", &h, &m, &s );
      lv[ i ] = h * 3600 + m * 60 + s;
      scanf ( " %d:%d:%d", &h, &m, &s );
      ar[ i ] = h * 3600 + m * 60 + s;
    }

    qsort ( lv, n, sizeof ( int ), comparator );
    qsort ( ar, n, sizeof ( int ), comparator );

    res = n;
    for ( j = 0; j < n; ++j )
    for ( i = 0; i < j; ++i )
    {
      if ( ar[ i ] <= lv[ j ] )
      {
        --res;
        ar[ i ] = INT_MAX;
        break ;
      }
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}