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<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL


typedef struct {
	int s;
	int g;
}time;
void swap_time(time *x, time *y) {
	time tmp = *x;
	*x = *y;
	*y = tmp;
}
void sort_by_s(time a[], int n) {
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j > i; j--) {
			if (a[j - 1].s > a[j].s)
				swap_time(&a[j - 1], &a[j]);
		}
	}
}
int main() {
	int n, hhs, mms, sss, hhg, mmg, ssg, cnt = 1;
	bool f[10000];
	time yamanote[10000];
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			char c;
			cin >> hhs >> c >> mms >> c >> sss >> hhg >> c >> mmg >> c >> ssg;
			yamanote[i].s = 3600 * hhs + 60 * mms + sss;
			yamanote[i].g = 3600 * hhg + 60 * mmg + ssg;
		}
		sort_by_s(yamanote, n);
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (f[j] == 1) { continue; }
				if (yamanote[i].s >= yamanote[j].g) {
					f[j] = 1;
					break;
				}
				if (j == i)cnt++;
			}
		}
		cout << cnt << endl;
		cnt = 1;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int timetable[60*60*24];
	
int main(void){
	int n;
	while(cin >> n,n){
		for(int i=0;i<60*60*24;i++)
			timetable[i]=0;
		for(int j=0;j<n;j++){
			string l,a;
			cin >> l >> a;
			int lh=atoi(l.substr(0,2).c_str());
			int lm=atoi(l.substr(3,2).c_str());
			int ls=atoi(l.substr(6,2).c_str());
			int ah=atoi(a.substr(0,2).c_str());
			int am=atoi(a.substr(3,2).c_str());
			int as=atoi(a.substr(6,2).c_str());
			int from=lh*60*60+lm*60+ls;
			int to=ah*60*60+am*60+as;
			for(int i=from;i<to;i++)
				timetable[i]++;
		}
		int cmax=0;
		for(int i=0;i<60*60*24;i++)
			cmax=max(cmax,timetable[i]);
		cout << cmax << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(24 * 60 * 60 + 1, 0);
		REP(i, n) {
			int h, m, s;
			char c;
			cin >> h >> c >> m >> c >> s;
			v[h * 60 * 60 + m * 60 + s]++;
			cin >> h >> c >> m >> c >> s;
			v[h * 60 * 60 + m * 60 + s]--;
		}
		REP(i, 24 * 60 * 60) {
			v[i + 1] += v[i];
		}
			cout << *max_element(ALL(v)) << endl;
	
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int N;
string In[10000], Out[10000];
int main() {
  while (cin >> N && N > 0) {
    for (int i=0; i<N; ++i) {
      cin >> Out[i] >> In[i];
      //    for (int i=0; i<N; ++i)
      //      cout << Out[i] << ' ' << In[i] << endl;
    }
      sort(In, In+N);
      sort(Out, Out+N);
    int p=0, taiki=0, train=0;
    for (int i=0; i<N; ++i) {
      while (p<N && In[p] <=Out[i]) {
	taiki++;
	p = p+1;
      }
      if (taiki > 0) taiki = taiki - 1;
      else train = train + 1;
    }
    cout << train << endl;
  }
}

C++: #include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  while(1){
    scanf("%d\n",&n);
    if(n==0){
      break;
    }
    int a,b,i;
    vector<int> x(216010);
    string s;
    for(i=0;i<n;i++){
      getline(cin,s);
      a=3600*((s[0]-'0')*10+(s[1]-'0'))+60*((s[3]-'0')*10+(s[4]-'0'))+((s[6]-'0')*10+(s[7]-'0'));
      b=3600*((s[9]-'0')*10+(s[10]-'0'))+60*((s[12]-'0')*10+(s[13]-'0'))+((s[15]-'0')*10+(s[16]-'0'));
      x[a]++,x[b]--;
    }
    for(i=0;i<=216005;i++){
      x[i+1]=x[i]+x[i+1];
    }
    int ans=0;
    for(i=0;i<=216005;i++){
      if(x[i]>ans){
        ans=x[i];
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}