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>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {

	while (1) {
		int n;
		int maxi = -1;
		int dp[86402] = {};
		int h, m, s;
		char c, d;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
			dp[h * 3600 + m * 60 + s]++;
			scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
			dp[h * 3600 + m * 60 + s ]--;
		}
		FOR(i, 1, 86401) {
			dp[i] += dp[i - 1];
		}
		FOR(i, 1, 86401) {
			if (dp[i] > maxi) {
				maxi = dp[i];
			}
		}
		cout << maxi << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

typedef pair<int, int> pii;

int main(){
  int n;
  while(cin >> n and n){
    vector<pii> event;
    REP(i, n){
      string arrv, dept;
      cin >> arrv >> dept;
      int hour, minute, sec;
      hour = arrv[0] * 10 + arrv[1];
      minute = arrv[3] * 10 + arrv[4];
      sec = arrv[6] * 10 + arrv[7];
      event.push_back(make_pair(hour * 3600 + minute * 60 + sec, 1));
      hour = dept[0] * 10 + dept[1];
      minute = dept[3] * 10 + dept[4];
      sec = dept[6] * 10 + dept[7];
      event.push_back(make_pair(hour * 3600 + minute * 60 + sec, 0));
    }
    sort(ALL(event));
    int res = 0;
    int tmp = 0;
    REP(i, event.size()){
      if(event[i].second) tmp++;
      else tmp--;
      res = max(tmp, res);
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef struct Time{
  int h;
  int m;
  int s;
}Time;
typedef pair<int,int> pii;
int main(){
  int n;
  Time s[10000],e[10000];
  vector<pii>::iterator ite;
  vector<pii> train; 
  while(cin>>n,n){
    train.clear();
    int ans=0,sum=0,i = 0;
    for(i = 0;i < n;i++){
      scanf("%d:%d:%d %d:%d:%d",&s[i].h,&s[i].m,&s[i].s,&e[i].h,&e[i].m,&e[i].s);
      train.push_back(pii(s[i].h*3600 + s[i].m*60 + s[i].s,1)); 
      train.push_back(pii(e[i].h*3600 + e[i].m*60 + e[i].s,0));
    }
    sort(train.begin(),train.end());
    ite = train.begin();
    while(ite != train.end()){
      if(ite->second == 1){
	sum++;
	ans=max(ans,sum);
      }else{
	sum--;
      }
      ite++;
    }
    cout<<ans<<endl;
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
ll sum[100100];

int main() {
	while (cin >> n&&n) {
		fill(sum, sum + 100100, 0);
		REP(i, n) {
			char c;
			int h, m, s;
			cin >> h >> c >> m >> c >> s;
			sum[h * 60 * 60 + m * 60 + s]++;
			cin >> h >> c >> m >> c >> s;
			sum[h * 60 * 60 + m * 60 + s]--;
		}
		ll ans = 0;
		REP(i, 100100 - 1) {
			sum[i + 1] += sum[i];
			ans = max(ans, sum[i]);
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int a[100000];

int cal(string str){
	int num[6];
	
	num[0] = str[0] - '0';
	num[1] = str[1] - '0';
	num[2] = str[3] - '0';
	num[3] = str[4] - '0';
	num[4] = str[6] - '0';
	num[5] = str[7] - '0';
	return num[0] * 36000 + num[1] * 3600 + num[2] * 600 + num[3] * 60 + num[4] * 10 + num[5];
}

int main(){
	
	int n;
	
	while(true){
		
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < 100000; i++){
			a[i] = 0;
		}
		
		
		for(int i = 0; i < n; i++){
			
			string str1, str2;
			cin >> str1 >> str2;
			
			a[cal(str1)]++;
			a[cal(str2)]--;
			
		}
		
		int ans = 0;
		int cur = 0;
		
		for(int i = 0; i < 100000; i++){
			cur += a[i];
			ans = max(ans, cur);
		}
		
		cout << ans << endl;
	}
	
	return 0;
}