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++: 
//=====================================================
// 
// (setq backup-inhibited t)
// (setq auto-save-default nil)
// 
// (column-number-mode t)
// (setq-default tab-width 2 indent-tabs-mode nil)
// 
// (global-set-key "\C-h" 'delete-backward-char)
// 
// (setq indent-line-function 'indent-relative-maybe)
// (global-set-key "\C-m" 'newline-and-indent)
// 
//=====================================================

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

bool comp(const pair<int, int>& lhs, const pair<int, int>& rhs) {
  return lhs.second > rhs.second;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if (!n) break;
    vector<int> v(86400);
    for (int i = 0; i < n; ++i) {
      int h[2],m[2],s[2];
      scanf("%d:%d:%d",&h[0],&m[0],&s[0]);
      scanf("%d:%d:%d",&h[1],&m[1],&s[1]);
      int bg = h[0]*3600 + m[0]*60 + s[0];
      int ed = h[1]*3600 + m[1]*60 + s[1];
      ++v[bg];
      --v[ed];
    }
    for (int i = 1; i < 86400; ++i) {
      v[i] += v[i-1];
    }
    cout << *max_element(begin(v), end(v)) << endl;
  }
  return 0;
}

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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 30
#define S second
#define F first
using namespace std;

int main(){
    int n, h1, h2, m1, m2, s1, s2;
    char str1[16], str2[16];
    while(scanf("%d", &n) && n){
        vector<pair<int, int> >time(n*2);
        rep(i, n){
            int a = 0, b = 0;
            pair<int, int>tmp;
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            a = h1 * 3600 + m1 * 60 + s1;
            b = h2 * 3600 + m2 * 60 + s2;
            time[i*2] = make_pair(a, 1);
            time[i*2+1] = make_pair(b, 0);
        }
        sort(time.begin(), time.end());
        int res = 0, cnt = 0;
        rep(i, time.size()){
            if(time[i].S){
                cnt++;
                res = max(res, cnt);
            }
            else cnt--;
        }
        
        printf("%d\n", res);
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

        vector<vector<int> > t(2, vector<int>(n));
        for(int i=0; i<n; ++i){
            for(int j=0; j<2; ++j){
                int h, m, s;
                char c;
                cin >> h >> c >> m >> c >> s;
                t[j][i] = (h * 60 + m) * 60 + s;
            }
        }
        sort(t.begin(), t.end());

        int ret = 0;
        vector<bool> check(n, false);
        for(int i=0; i<n; ++i){
            if(!check[i])
                ++ ret;
            for(int j=i+1; j<n; ++j){
                if(t[0][j] >= t[1][i] && !check[j]){
                    check[j] = true;
                    break;
                }
            }
        }
        cout << ret << endl;
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<map>
#include<algorithm>
#define mp make_pair
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> pi;
char in[20];
int n;
pi table[20000];
int main(){
	while(scanf("%d",&n),n){
		rep(i,n)rep(j,2){
			cin>>in;
			table[i*2+j]=mp(atoi(in)*3600+atoi(&in[3])*60+atoi(&in[6]),1-j);
		}
		sort(table,table+2*n);
		int ans=0,c=0;
		rep(i,2*n){
			if(table[i].second)
				c++;
			else c--;
			ans=max(ans,c);
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  vector<int> st;
  vector<int> fi;
  int n,t;
  int c,m;
  string T;
  while(1){
    c=0;
    m=0;
    st.empty();
    fi.empty();
    //
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> T;
      t=(T[0]-'0')*36000+(T[1]-'0')*3600+(T[3]-'0')*600+(T[4]-'0')*60+(T[6]-'0')*10+T[7]-'0';
      st.push_back(t);
      cin >> T;
      t=(T[0]-'0')*36000+(T[1]-'0')*3600+(T[3]-'0')*600+(T[4]-'0')*60+(T[6]-'0')*10+T[7]-'0';
      fi.push_back(t);
    }
    sort(st.begin(),st.end());
    sort(fi.begin(),fi.end());
    int i1=0,i2=0;
    while(1){
      if(st[i1]<fi[i2]&&i1!=n){
	i1++;
	c++;
	m=max(m,c);
      }
      else{
	i2++;
	c--;
	if(i2==n)break;
      }
    }
    cout << m << endl;
  }
  return 0;
}