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 <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

bool a[10000];
int sh[10000], sm[10000], ss[10000], eh[10000], em[10000], es[10000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {

		int n;
		cin >> n;
		if(!n) break;

		rep(i,0,n) {
			int sH,sM,sS,eH,eM,eS;
			scanf("%d:%d:%d %d:%d:%d", &sH, &sM, &sS, &eH, &eM, &eS);
			sh[i] = sH;
			sm[i] = sM;
			ss[i] = sS;
			eh[i] = eH;
			em[i] = eM;
			es[i] = eS;
			a[i] = true;
		}

		int num = 0, ans = 0;
		while(num < n) {
			int x = 0;
			rep(i,0,n) {
				if(a[i]) {
					x = i;
					num++;
					ans++;
					a[i] = false;
					break;
				}
			}

			rep(i,x+1,n) {
				bool flag = false;
				if(a[i]) {
					if(eh[x] < sh[i]) flag = true;
					else if(eh[x] == sh[i]) {
						if(em[x] < sm[i]) flag = true;
						else if(em[x] == sm[i]) {
							if(es[x] <= ss[i]) flag = true;
						}
					}
				}

				if(flag) {
					a[i] = false;
					x = i;
					num++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int st[10001];
int fn[10001];

int main()
{
    int n;

    while (cin >> n, n) {
        int h, m, s;
        char ch;
        int ans = 0;

        for (int i = 0; i < n; i++) {
            cin >> h >> ch >> m >> ch >> s;
            st[i] = (h * 60 + m) * 60 + s;
            cin >> h >> ch >> m >> ch >> s;
            fn[i] = (h * 60 + m) * 60 + s;
        }

        sort(st, st + n);
        sort(fn, fn + n);

        int i_s, i_f, tmp;
        i_s = i_f = tmp = 0;
        while (i_s < n && i_f < n) {
            if (st[i_s] < fn[i_f]) {
                i_s++;
                tmp++;
                ans = max(ans, tmp);
            }
            else {
                i_f++;
                tmp--;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int t[24][60][60];

void read_time(int& h, int& m, int& s) {
    string str;
    cin >> str;
    replace(ALL(str), ':', ' ');
    stringstream ss(str);
    ss >> h >> m >> s;
}

int main() {
    int n;
    while (cin >> n, n) {
        fill_n((int *)t, 24*60*60, 0);
        REP(i, n) {
            int sh, sm, ss, eh, em, es;
            read_time(sh, sm, ss);
            read_time(eh, em, es);
            bool ok = false;
            REP(h, 24) {
                REP(m, 60) {
                    REP(s, 60) {
                        if (h == eh && m == em && s == es) {
                            goto NEXT;
                        }
                        if (ok) t[h][m][s]++;
                        if (h == sh && m == sm && s == ss) {
                            ok = true;
                        }
                    }
                }
            }
NEXT: {}
        }
        int ma = 0;
        REP(h, 24) {
            REP(m, 60) {
                REP(s, 60) {
                    ma = max(ma, t[h][m][s]);
                }
            }
        }
        cout << ma << endl;
    }
}