Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		accum := make([]int, 86401)
		for i := 0; i < n; i++ {
			s, e := io.Next(), io.Next()
			hs, _ := strconv.Atoi(s[:2])
			ms, _ := strconv.Atoi(s[3:5])
			ss, _ := strconv.Atoi(s[6:8])
			accum[hs*60*60+ms*60+ss]++
			he, _ := strconv.Atoi(e[:2])
			me, _ := strconv.Atoi(e[3:5])
			se, _ := strconv.Atoi(e[6:8])
			accum[he*60*60+me*60+se]--
		}
		ans := 0
		for i := 1; i < 86401; i++ {
			accum[i] += accum[i-1]
			ans = intMax(accum[i], ans)
		}
		io.Println(ans)
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
            return false;
        }
    }
    return true;
}

int toint(string s) {
    string b;
    copy_if(all(s), back_inserter(b), [] (char c) { return c != ':'; });
    return stoi(b);
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int n; cin >> n;
        if (!n) break;
        vector<pii> v;
        rep(i, 0, n) {
            string a, b; cin >> a >> b;
            v.push_back({toint(a), toint(b)});
        }
        sort(all(v));
        multiset<int, greater<int>> ends;
        for (auto p : v) {
            int s, e; tie(s, e) = p;
            // cout << s << " " << e << ";; ";
            // for (int h : ends) cout << h << " ";
            // cout << endl;
            if (ends.empty()) ends.insert(e);
            else {
                // cout << "find: " << s << endl;
                auto it = ends.lower_bound(s);
            
                // if (it == ends.end()) cout << "NF" << endl;
                // else cout << *it << endl;

                if (it == ends.end()) ends.insert(e);
                else {
                    ends.erase(it);
                    ends.insert(e);
                }
            }
        }
        cout << ends.size() << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define N 86400
int main() {
	int n, time[N], max, num, h, m, s;
	while (cin >> n, n) {
		max = 0; num = 0;
		for (int i = 0; i < N; ++i) time[i] = 0;
		for (int i = 0; i < n; ++i) {
			scanf("%02d:%02d:%02d", &h, &m, &s);
			++time[h * 3600 + m * 60 + s];
			scanf("%02d:%02d:%02d", &h, &m, &s);
			--time[h * 3600 + m * 60 + s];
		}
		for (int i = 0; i < N; ++i) {
			num += time[i];
			if (max < num) max = num;
		}
		cout << max << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<string.h>
using namespace std;

int convert(string s){
	int h=(s[0]-'0')*10+(s[1]-'0');
	int m=(s[3]-'0')*10+(s[4]-'0');
	int t=(s[6]-'0')*10+(s[7]-'0');
	return h*3600+m*60+t;
}

class range{
public:
	int left,right;
	range(int left,int right):left(left),right(right){}
	range(){};
};

bool is_connect(range a,range b){
	if(a.right<=b.left || b.right<=a.left) return false;
	return true;
}


int main()
{
	int n;
	while(cin>> n && n!=0){
		vector<range> V(n);
		for(int i=0;i<n;i++){
			string s,t;cin>>s>>t;
			V[i].left=convert(s);
			V[i].right=convert(t);
		}

		int ans[24*3600+60*60+60+1];
		memset(ans,0,sizeof(ans));
		for(int i=0;i<n;i++){
			for(int k=V[i].left;k<V[i].right;k++){
				ans[k]++;
			}
		}

		int res=0;
		for(int i=0;i<=24*3600+60*60+60;i++){
			res=max(res,ans[i]);
		}
		cout<<res<<endl;



	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	while(cin >> N, N){
    	int range[24*60*60+1];
    	fill(range, range+24*60*60+1, 0);
		for(int i = 0; i < N; ++i){
			int h[2], m[2], s[2];
   	 	 	scanf("%2d:%2d:%2d", &h[0], &m[0], &s[0]);
     	 	scanf("%2d:%2d:%2d", &h[1], &m[1], &s[1]);
     	 	int st = h[0]*60*60+m[0]*60+s[0], et = h[1]*60*60+m[1]*60+s[1];
     	 	++range[st], --range[et];
    	}
    	int ans = 0, acc = 0;
		for(int i = 0; i < 24*60*60; ++i){
    		acc += range[i];
      		ans = max(ans, acc);
    	}
    	cout << ans << endl;
  	}
   
  return 0;
}