#include <iostream>
#include <string>
#include <stdlib.h>
#define llint long long

using namespace std;

llint n;
llint diff[100005];
string s, t;

int calc(string s)
{
  int h = atoi(s.substr(0, 2).c_str());
  int m = atoi(s.substr(3, 2).c_str());
  int b = atoi(s.substr(6, 2).c_str());
  return h * 3600 + m * 60 + b;
}

int main(void)
{
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < 100005; i++) diff[i] = 0;
    for(int i = 1; i <= n; i++){
      cin >> s >> t;
      diff[calc(s)]++, diff[calc(t)]--;
    }
    llint ans = diff[0];
    for(int i = 1; i < 100005; i++){
      diff[i] += diff[i-1];
      ans = max(ans, diff[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

