import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

struct E {
    int time;
    int c;
}

int N;
E[] es;
bool input() {
    scanf("%d\n", &N);
    if (N == 0) return false;
    foreach (i; 0 .. N) {
        int h, m, s;
        scanf("%d:%d:%d", &h, &m, &s);
        int from = h * 3600 + m * 60 + s;
        es ~= E(from, +1);
        scanf(" %d:%d:%d\n", &h, &m, &s);
        int to = h * 3600 + m * 60 + s;
        es ~= E(to, -1);
    }
    return true;
}

void solve() {
    es.sort!"a.time < b.time";
    int ans = 0;
    int pool = 0;
    foreach (e; es) {
        if (e.c == 1) {
            if (pool > 0) pool--;
            else ans++;
        } else {
            assert(e.c == -1);
            pool++;
        }
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}