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 <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;

        vector<int> imos(100000, 0);
        for(int i=0; i<n; i++){
            int h1, m1, s1;
            char a1, b1;
            cin>>h1>>a1>>m1>>b1>>s1;

            int h2, m2, s2;
            char a2, b2;
            cin>>h2>>a2>>m2>>b2>>s2;

            int startTime = h1 * 3600 + m1 * 60 + s1;
            int stopTime = h2 * 3600 + m2 * 60 + s2;

            imos[startTime]++;
            imos[stopTime]--;
        }

        int ans=imos[0];
        for(int i=0; i<=90000; i++){
            imos[i+1] += imos[i];
            chmax(ans, imos[i+1]);
        }

        cout << ans << endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,0,0},dy[]={1,0,-1,0,0,0};
int dz[]={0,0,0,0,1,-1};

int st[10000];
int ed[10000];
int n;

void solve(){
  priority_queue<PI> q;
  rep(i,n){
    int hh,mm,ss;
    scanf("%d:%d:%d",&hh,&mm,&ss);
    st[i]=hh*3600+mm*60+ss;
    q.push(mp(-st[i],0));
    scanf("%d:%d:%d",&hh,&mm,&ss);
    ed[i]=hh*3600+mm*60+ss;
    q.push(mp(-ed[i],1));
  }
  int ans=0;
  int cu=0;
  while(!q.empty()){
    int cc=q.top().S;
    q.pop();
    cu+=cc;
    if(cc==0 && cu==0)++ans;
    else if(cc==0)--cu;
  }
  cout<<ans<<endl;
}


main(){
  while(cin>>n,n)
    solve();
}

C++: #include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main () {
	int n;
	while (scanf("%d", &n), n) {
		int recode[24 * 60 * 60];
		memset(recode, 0, sizeof(recode));
		for (int i = 0; i < n; i++) {
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			recode[h * 60 * 60 + m * 60 + s] += 1;
			scanf("%d:%d:%d", &h, &m, &s);
			recode[h * 60 * 60 + m * 60 + s] -= 1;
		}
		int current = 0, result = 0;
		for (int i = 0; i < 24 * 60 * 60; i++) {
			current += recode[i];
			result = max(current, result);
		}
		printf("%d\n", result);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
 
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
 
#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)
 
typedef long long ll;
typedef pair<int, int> pii;


int main(void)
{
	int n;
	while (cin >> n, n) {
		vector< pair<string, string> > vs;

		rep(i, n) {
			string a, b;
			cin >> a >> b;
			vs.push_back(make_pair(a, "START"));
			vs.push_back(make_pair(b, "END"));
		}
		sort(ALL(vs));

		int ans = 0, cnt = 0;
		rep(i, vs.size()) {
			if (vs[i].second == "START")
				cnt++;
			else
				cnt--;
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
    return 0;
}