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>
#include<algorithm>


using namespace std;

const int INF=1e+8;

typedef struct{
	int start,end;
	bool labelFlag;
}jikan;

int jikanShori(int h,int m,int s){
	return h*3600+m*60+s;
}


//比較関数
int comp(const void *c1,const void *c2){
	jikan jikan1=*(jikan *)c1;
	jikan jikan2=*(jikan *)c2;
	
	int tmp1=jikan1.start;
	int tmp2=jikan2.start;
	
	return tmp1-tmp2;
}

int main(){
	int n,cnt,ans;
	int h,m,s;
	jikan interval[10000];
	
	
	while(cin>>n,n){
		cnt=1;
		ans=1;
		for(int i=0;i<10000;i++){
			interval[i].start=INF;
			interval[i].end=INF;
			interval[i].labelFlag=false;
		}
		
		for(int i=0;i<n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].start=jikanShori(h,m,s);
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].end=jikanShori(h,m,s);
		}
		
		qsort(interval,10000,sizeof(jikan),comp);
		
		for(int i=0;i<n;i++){
			cnt=1;
			if(!interval[i].labelFlag){
				interval[i].labelFlag=true;
				for(int j=i+1;j<n;j++){
					if(interval[i].end>interval[j].start){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
			ans=max(ans,cnt);
		}
		
		cout<<ans<<endl;
	}
}

C++:  #include<stdio.h>
#include<iostream>
using namespace std;
long long int N[10000000]={};
int main(){

int n,q;
int h1=0,m1=0,s1=0,h2=0,m2=0,s2=0;
while(1){
cin>>n;if(n==0)break;
for(int i=0;i<n;i++)
{scanf("%d:%d:%d",&h1,&m1,&s1);
scanf("%d:%d:%d",&h2,&m2,&s2);
long int L1=h1*3600+m1*60+s1;
long int L2=h2*3600+m2*60+s2;
for(int j=L1;j<L2;j++)
	N[j]++;
}
int max=0;
for(int i=0;i<=90800;i++)
{if(N[i]>max)max=N[i];}
cout<<max<<endl;
}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll ans=0;
int main(){
    while(true){
        ll a;cin >> a;
        if(!a)break;
        vl v(86400,0);
        rep(i,a){
            string s,g;cin >> s >>g;
            ll l=0,r=0;
            l+=(s[0]-'0')*10*3600+(s[1]-'0')*3600;
            l+=(s[3]-'0')*10*60+(s[4]-'0')*60;
            l+=(s[6]-'0')*10+(s[7]-'0')*1;
            r+=(g[0]-'0')*10*3600+(g[1]-'0')*3600;
            r+=(g[3]-'0')*10*60+(g[4]-'0')*60;
            r+=(g[6]-'0')*10+(g[7]-'0')*1;
            v[l]++;
            if(r<86400)v[r]--;
        }
        vl imos(86401,0);
        rep(i,86400)imos[i+1]+=imos[i]+v[i];
        ll ans=0;
        rep(i,86401)chmax(ans,imos[i]);
        cout <<ans <<endl;
    }
}

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


typedef struct{
	int start,end;
	bool labelFlag;
}jikan;

int jikanShori(int h,int m,int s){
	return h*3600+m*60+s;
}

int main(){
	int n,cnt,ans;
	int h,m,s;
	jikan interval[10000];
	
	for(int i=0;i<10000;i++){
		interval[i].start=0;
		interval[i].end=0;
		interval[i].labelFlag=false;
	}
	while(cin>>n,n){
		cnt=1;
		ans=1;
		for(int i=0;i<10000;i++){
			interval[i].start=0;
			interval[i].end=0;
		}
		
		for(int i=0;i<n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].start=jikanShori(h,m,s);
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].end=jikanShori(h,m,s);
		}
		
		//sort(interval,interval+n,LessStart);
		
		for(int i=0;i<n;i++){
			cnt=1;
			if(!interval[i].labelFlag){
				interval[i].labelFlag=true;
				for(int j=i+1;j<n;j++){
					if(interval[i].end>interval[j].start && 
									!interval[j].labelFlag){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
			ans=max(ans,cnt);
		}
		
		cout<<ans<<endl;
	}
}