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

// > (8+1)*2
#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

struct time {
    int hh;
    int mm;
    int ss;
};

int to_ss(struct time *t) {
    return t->hh * 3600 + t->mm * 60 + t->ss;
}

#define HHMMSS_FMT "%02d:%02d:%02d"
#define LIMIT_TIME (3600*24)

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  struct time t1, t2;
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, HHMMSS_FMT " " HHMMSS_FMT,
    &t1.hh, &t1.mm, &t1.ss,
    &t2.hh, &t2.mm, &t2.ss
  );
  *a1 = to_ss(&t1);
  *a2 = to_ss(&t2);
#else
#error
#endif
  return 0;
}

#define ANS_MAX 10000
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int main(void) {
    int ans[ANS_MAX];
    int ans_idx = 0;
    int i, j;
    static int diff[LIMIT_TIME] = {0};
    while(1) {
        int num = get_int();
        if(!num) break;
        int ulimit = 0;
        memset(diff, 0, sizeof(int)*LIMIT_TIME);
        int llimit = LIMIT_TIME;
        for(i = 0; i < num; i++) {
            int start, end;
            get_int2(&start, &end);
#ifdef DEBUG
            printf("%d -> %d\n", start, end);
#endif
            diff[start]++;
            diff[end]--;
            ulimit = max(ulimit, end);
            llimit = min(llimit, start);
        }
        int cum = 0;
        int res = 0;
        for(i = llimit; i <= ulimit; i++) {
            cum += diff[i];
            res = max(res, cum);
        }
        ans[ans_idx++] = res;
    }
    for(i = 0; i < ans_idx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}
