import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


enum lim = 24 * 3600 + 1;

void main() {
    while (true) {
        int n;
        scan(n);
        if (!n) return;
        auto c = new int[](lim);
        foreach (i ; 0 .. n) {
            string s, t;
            scan(s, t);
            auto l = toSec(s);
            auto r = toSec(t);
            c[l]++;
            c[r]--;
        }
        foreach (i ; 1 .. lim) {
            c[i] += c[i-1];
        }
        auto ans = c.reduce!max;
        writeln(ans);
    }
}

int toSec(string hms) {
    int res;
    res += hms[0 .. 2].to!int * 3600;
    res += hms[3 .. 5].to!int * 60;
    res += hms[6 .. 8].to!int;
    return res;
}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}
