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;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n;
    while(cin>>n,n){
        vector<P> vec;
        REP(i,2*n){
            int h,m,s;
            char c;
            cin>>h>>c>>m>>c>>s;
            int time=3600*h+60*m+s;
            vec.push_back(P(time,(i+1)%2));
        }
        sort(ALL(vec));

        int ans=0,cnt=0;
        REP(i,2*n){
            if(vec[i].second){
                cnt++;
                ans=max(ans,cnt);
            }else{
                cnt--;
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include<iostream>

#define secondMAX (23*60*59+60*60+59)
using namespace std;

int main(){

	int n;
	int h,m,s;
	char gav;
	int table[secondMAX+1];
	int max;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<=secondMAX;i++) table[i]=0;
		for(int i=0;i<n;i++){
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]+=1;
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]-=1;
		}
		for(int i=1;i<=secondMAX;i++) table[i]+=table[i-1];
		max=0;
		for(int i=0;i<=secondMAX;i++){
			if(max<table[i]) max=table[i];
		}

		cout<<max<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int a[24 * 60 * 60+10];
int main() {
	long long a1, m1, a2, m2, a3, m3;
	int n;
	while (cin >> n&&n != 0) {
		int h1, m1, s1, h2, m2, s2;
		fill(a, a + 60 * 24 * 60+10, 0);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			bool k = false;
			for (int i = h1 * 3600 + m1 * 60 + s1; i<h2 * 3600 + m2 * 60 + s2; i++) {
				a[i]--;
				if (a[i] < 0) {
					sum++;
					for (int i = 0; i < 24 * 60 * 60+10; i++) a[i]++;
				}
			}
		}
		cout << sum << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n,ma;
	string s,t;
	vector<int> box;
	while(cin>>n,n){
		ma=0;
		for(int i=0;i<=24*60*60;i++)
		box.push_back(0);
		for(int i=0;i<n;i++){
			cin>>s>>t;
			for(int j=((s[0]-'0')*10+s[1]-'0')*3600+((s[3]-'0')*10+s[4]-'0')*60+(s[6]-'0')*10+s[7]-'0';j<((t[0]-'0')*10+t[1]-'0')*3600+((t[3]-'0')*10+t[4]-'0')*60+(t[6]-'0')*10+t[7]-'0';j++){
				
				box[j]++;
			}
		}
		for(int i=0;i<=24*60*60;i++)
		if(ma<box[i])
		ma=box[i];
		cout<<ma<<endl;
		box.clear();
	}
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


bool larger(pair<int, int> x, pair<int, int> y){
    return x.first < y.first;
}
int main(){
    int N=1;
    while(cin >> N && N){

    	vector<pair<int,int> >dia;
    	for(int i =0;i< N;i++){
    		vector<string>ss;
    		string st;
    		cin >> st;
    		ss.push_back(st);
    		cin >> st;
    		ss.push_back(st);
    		pair<int,int>buf(0,0);
    		buf.first = (ss[0][0]*10+ss[0][1])*3600+(ss[0][3]*10+ss[0][4])*60+(ss[0][6]*10+ss[0][7]);
    		
    		buf.second = (ss[1][0]*10+ss[1][1])*3600+(ss[1][3]*10+ss[1][4])*60+(ss[1][6]*10+ss[1][7]);
    		dia.push_back(buf);

    	}
	sort(dia.begin(),dia.end(),larger);
    	int ans =0;
    	vector<int>used;
    		for(int i =0;i< dia.size();i++){
    			bool us = true;
    			for(int j =0;j < used.size();j++){
    				if(i==used[j])us = false;
    			}
    			if(us){
    				ans +=1;
    				used.push_back(i);
    				int now=dia[i].second;
    				for(int k = i+1;k< dia.size();k++){
    					bool s = true;
                        int a = used.size();
                        for(int l =0;l < a;l++){
                            if(used[l] == k)s = false;
                        }
                        if(now <= dia[k].first && s){
    						now = dia[k].second;
    						used.push_back(k);
    					}
    				}
    			}
    		}
    	cout << ans << endl;
    }
}