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 <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;


struct st{
	bool flag;
	int b;
	int e;
	
	st(int b, int e) : b(b), e(e), flag(true) {}
	
	bool operator< (const st &a)const{
		return (*this).e < a.e;
	}
};

bool solve(){
	
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<st> vst;
	for(int k=0;k<n;k++){
		int in[2] = {0};
		for(int i=0;i<2;i++){
			int h,m,s;
			char c[2];
			cin>> h>> c[0]>> m>> c[1]>> s;
			in[i] = 3600 * h + 60 * m + s;
		}
		st a(in[0], in[1]);
		vst.push_back(a);
	}
	//for(int k=0;k<n;k++) cout<< vst[k].b<< " "<< vst[k].e<< endl;
	
	int ans = 0;
	int cnt = 0;
	sort(vst.begin(), vst.end());
	while(cnt != vst.size()){
		int t=0;
		for(int i=0;i<vst.size();i++){
			if(vst[i].flag == true && t <= vst[i].b){
				vst[i].flag = false;
				t = vst[i].e;
				cnt++;
			}
		}
		ans++;
	}
	
	cout<< ans<< endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

void solve(int n){
  int h,m,s;
  int imos[86405];
  rep(i,86405)imos[i]=0;
  cin>>n;
  rep(i,n){
    scanf("%2d:%2d:%2d",&h,&m,&s);
    imos[h*3600+m*60+s]++;
    scanf("%2d:%2d:%2d",&h,&m,&s);
    imos[h*3600+m*60+s+1]--;
  }
  REP(i,1,86405)imos[i]+=imos[i-1];
  int ans=0;
  rep(i,86405){
    ans=max(ans,imos[i]);
  }
  cout<<ans<<endl;
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    solve(n);
  }
  return 0;
}

C++: #include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n;
	while(cin>>n&&n!=0){
		int a[86400]={};
		for(int i=0;i<n;i++){
			string s,t;
			cin>>s;
			int from= ((s[0]-'0')*10+ (s[1]-'0'))*3600
					+ ((s[3]-'0')*10+ (s[4]-'0'))*60
					+ ((s[6]-'0')*10+ (s[7]-'0'));
			cin>>t;
			int to= ((t[0]-'0')*10+ (t[1]-'0'))*3600
					+ ((t[3]-'0')*10+ (t[4]-'0'))*60
					+ ((t[6]-'0')*10+ (t[7]-'0'));
			for(int j=from;j<to;j++){
				a[j]++;
			}
		}
		
		sort(a,a+86400);
		cout<<a[86399]<<endl;
		
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

        vector<int> diagram(100000,0);
        REP(i,n){
            string s,t;
            cin >> s >> t;
            int s_seconds = (s[7]-'0') + 10*(s[6]-'0') + 60*((s[4]-'0') + 10*(s[3]-'0')) + 3600*((s[1]-'0') + 10*(s[0]-'0'));
            int t_seconds = (t[7]-'0') + 10*(t[6]-'0') + 60*((t[4]-'0') + 10*(t[3]-'0')) + 3600*((t[1]-'0') + 10*(t[0]-'0'));
            diagram[s_seconds]++;
            diagram[t_seconds]--;
        }
        int ans = 0;
        REP(i,90000){
            diagram[i+1] += diagram[i];
            ans = max(ans, diagram[i]);
        }
        cout << ans << endl;
    }
    return 0;
}