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<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int main(){
	int n,hh[2],mm[2],ss[2];
	while(cin>>n,n){
		int time[86500];
		rep(i,86500)time[i]=0;
		rep(i,n){
			scanf("%d:%d:%d",&hh[0],&mm[0],&ss[0]);
			scanf("%d:%d:%d",&hh[1],&mm[1],&ss[1]);
			time[hh[0]*3600+mm[0]*60+ss[0]]++;
			time[hh[1]*3600+mm[1]*60+ss[1]]--;	
		}
		rep(i,86490){
			time[i+1]+=time[i];
		}
		int inf=0;
		rep(i,86500){
			if(time[i]==0)continue;
			else if(inf<time[i]){
				inf=time[i];
			}
		}
		cout<<inf<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int timetable[60*60*24];
	
int main(void){
	int n;
	while(cin >> n,n){
		for(int i=0;i<60*60*24;i++)
			timetable[i]=0;
		for(int j=0;j<n;j++){
			string l,a;
			cin >> l >> a;
			int lh=atoi(l.substr(0,2).c_str());
			int lm=atoi(l.substr(3,2).c_str());
			int ls=atoi(l.substr(6,2).c_str());
			int ah=atoi(a.substr(0,2).c_str());
			int am=atoi(a.substr(3,2).c_str());
			int as=atoi(a.substr(6,2).c_str());
			int from=lh*60*60+lm*60+ls;
			int to=ah*60*60+am*60+as;
			for(int i=from;i<to;i++)
				timetable[i]++;
		}
		int cmax=0;
		for(int i=0;i<60*60*24;i++)
			cmax=max(cmax,timetable[i]);
		cout << cmax << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int time[86401]={0},n,start,end;
	string str[2],se;
	vector<string> vec;
	string h,m,s,eh,em,es;
	while(cin>>n,n){
		cin.ignore();
		rep(i,86401)time[i]=0;
		string tmp="";
		rep(i,n){
			getline(cin,se);
			rep(j,se.size()){
				if(se[j]==' '){
					str[0]=tmp;
					tmp="";
				}else{
					tmp+=se[j];
				}
			}
			str[1]=tmp;
			tmp="";
			vec.clear();
			rep(j,2){
				rep(i,str[j].size()){
					if(str[j][i]==':'){
						vec.push_back(tmp);
						tmp="";
					}else{
						tmp+=str[j][i];					
					}
				}
				vec.push_back(tmp);
				tmp="";
			}
			h=vec[0];
			m=vec[1];
			s=vec[2];
			eh=vec[3];
			em=vec[4];
			es=vec[5];
			start=((int)(h[0]-'0')*10+(int)(h[1]-'0'))*60*60+((int)(m[0]-'0')*10+(int)(m[1]-'0'))*60+((int)(s[0]-'0')*10+(int)(s[1]-'0'));
			time[start]++;
			end=((int)(eh[0]-'0')*10+(int)(eh[1]-'0'))*60*60+((int)(em[0]-'0')*10+(int)(em[1]-'0'))*60+((int)(es[0]-'0')*10+(int)(es[1]-'0'));
			time[end]--;
		}
		rep(i,86401){
			time[i+1]+=time[i];
		}
		int maximum=0;
		rep(i,86401){
			maximum=max(maximum,time[i]);
		}
		cout<<maximum<<endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int t[444000];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		memset(t,0,sizeof(t));
		rep(i,n){
			int h,m,s;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]+=1;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]-=1;
			//dbg(h); dbg(m); dbg(s);
		}
		rep(i,444000){
			t[i+1]+=t[i];
		}
		int res=0;
		rep(i,444000){
			maxch(res,t[i]);
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n;
    while (cin >> n, n) {
        vector<int> line(24*60*60 + 1, 0);
        rep(i, n) {
            int h, m, n;
            scanf("%d:%d:%d", &h, &m, &n);
            m += h * 60;
            n += m * 60;
            line[n]++;
            scanf("%d:%d:%d", &h, &m, &n);
            m += h * 60;
            n += m * 60;
            line[n]--;
        }
        int ret = 0;
        rep(i, 24*60*60) {
            line[i+1] += line[i];
            ret = max(ret, line[i]);
        }
        cout << ret << endl;
    }
    return 0;
}