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

#define N 10000
#define INT(X) \
  ( *( (const int *)(X) ) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

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

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

  for ( ; ; )
  {
    int ev[ N * 2 ];
    int nanikaka = 0;
    int res = 0;
    int n;

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

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

      scanf ( " %d:%d:%d", &h, &m, &s );
      ev[ i ] = ( ( h * 3600 + m * 60 + s ) << 1 ) + !( i % 2 );
    }

    qsort ( ev, n * 2, sizeof ( int ), compare );

    for ( i = 0; i < n * 2; ++i )
    {
      nanikaka += 2 * ( ev[ i ] & 1 ) - 1;
      res = MAX( res, nanikaka );
    }

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

  return ( 0 );
}