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 <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int t[90000];

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

	while(true) {
		int n;
		cin >> n;
		if(!n) break;

		rep(i,0,90000) t[i] = 0;
		rep(i,0,n) {
			int h,m,s;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]++;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]--;
		}

		int ans = -1, tmp = 0;
		rep(i,0,90000) {
			tmp += t[i];
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int fanc(string s){
    int res = 0;
    int tmp = 0;
    tmp += (int)(s[7] - '0');
    tmp += 10*(int)(s[6] - '0');
    res += tmp;
    tmp = 0;
    tmp += (int)(s[4] - '0');
    tmp += 10*(int)(s[3] - '0');
    res += tmp * 60;
    tmp = 0;
    tmp += (int)(s[1] - '0');
    tmp += 10*(int)(s[0] - '0');
    res += tmp * 3600;
    return res;
}

int main(){

    while(1){
    
        int n; cin >> n;
        if(!n) break;

        int imos[100000] = {};        
        for(int i = 0; i < n; i++){
            string s, t; cin >> s >> t;
            int S = fanc(s);
            int T = fanc(t);        
            imos[T]--;
            imos[S]++;
        }

        for(int i = 1; i < 100000; i++){
            imos[i] += imos[i - 1];
        }

        int ans = 0;
        for(int i = 0; i < 100000; i++){
            ans = max(ans, imos[i]);
        }

        cout << ans << endl;
    }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#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 repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct train{
  string s,t;
};

struct Comp{
  bool operator()(pair<string,string> a,pair<string,string> b)const{
    return a.fi < b.fi;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  ll n;
  while(cin >> n && n){
    vector<train> ans;
    vector<pair<string,string>> v(n);
    rep(i,n){
      cin >> v[i].fi >> v[i].se;
    }
    sort(all(v),Comp());
    ans.push_back({v[0].fi,v[0].se});
    REP(i,1,n){
      bool f = false;
      rep(j,ans.size()){
        if(ans[j].t <= v[i].fi){
          ans[j] = {v[i].fi,v[i].se};
          f = true;
          break;
        }
      }
      if(!f) ans.push_back({v[i].fi,v[i].se});
    }
    cout << ans.size() << endl;
  }
  return 0;
}

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 && 
									!interval[j].labelFlag){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
			ans=max(ans,cnt);
		}
		
		cout<<ans<<endl;
	}
}