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;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif
const int time_pow[3] = { 3600, 60, 1 };

int main(){
    while(true) {
        int n;
        cin >> n;

        if(n == 0) return 0;

        vector<int> train(1e5, 0);
        for (auto i = 0; i < n; i++) {
            string s, t; cin >> s >> t;
            int s_index = 0, t_index = 0;
            for (auto j = 0; j < 3; j++) {
                s_index += time_pow[j] * stoi(s.substr(j * 3, 2));
                t_index += time_pow[j] * stoi(t.substr(j * 3, 2));
            }
            train[s_index]++;
            train[t_index]--;
        }

        for (auto i = 0; i < 1e5 - 1; i++) train[i + 1] += train[i];

        int ans = 0;
        for (auto i = 0; i < 1e5; i++) ans = max(ans, train[i]);
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int toI(char c)
{
	return c - '0';
}
int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		vector<pair<int, int> >range;
		vector<pair<int, int> > ansRange[10000 + 1];
		int ans = 1;
		for (int i = 0; i < n; i++)
		{
			pair<int, int> p;
			char line[15];
			cin >> line;
			int hour = toI(line[0]) * 10 + toI(line[1]);
			int minute = toI(line[3]) * 10 + toI(line[4]);
			int second = toI(line[6]) * 10 + toI(line[7]);
			p.first = hour * 60 * 60 + minute * 60 + second;
			cin >> line;
			hour = toI(line[0]) * 10 + toI(line[1]);
			minute = toI(line[3]) * 10 + toI(line[4]);
			second = toI(line[6]) * 10 + toI(line[7]);

			p.second = hour * 60 * 60 + minute * 60 + second;
			range.push_back(p);
		}
		sort(range.begin(), range.end());
		ansRange[0].push_back(range[0]);
		for (int i = 1; i < n; i++)
		{
			bool flag = false;
			for (int j = 0; j < ans; j++)
			{
				for (int k = 0; k < ansRange[j].size(); k++)
				{
					if (range[i].first >= ansRange[j].at(k).second || range[i].second < ansRange[j].at(k).first)
					{
						ansRange[j].push_back(range[i]);
						flag = true;
						break;
					}
				}

				if (flag)break;
			}
			if (!flag)
			{
				ans++;
				ansRange[ans - 1].push_back(range[i]);
			}
		}

		cout << ans << endl;
	}
	return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

const int M = 24 * 60 * 60 + 10;

int solve(int n) {
    VI cnts(M);
    
    rep(i, n) {
        int a, b, c, x, y, z;
        scanf("%d:%d:%d", &a, &b, &c);
        scanf("%d:%d:%d", &x, &y, &z);
        int s = a * 60 * 60 + b * 60 + c;
        int t = x * 60 * 60 + y * 60 + z;
        cnts[s] += 1;
        cnts[t] -= 1;
    }

    partial_sum(ALL(cnts), cnts.begin());

    return *max_element(ALL(cnts));
}

int main(void) {
    int n;
    while (cin >> n, n) cout << solve(n) << endl;

    return 0;
}