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"

#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) {
		cout << *max_element(ALL(v)) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <tuple>
#include <set>
#include <queue>
using namespace std;
struct hms_t {
    int h, m, s;
};
bool operator < (hms_t const & a, hms_t const & b) {
    return make_tuple(a.h, a.m, a.s) < make_tuple(b.h, b.m, b.s);
}
struct event_t {
    hms_t time;
    int train;
    bool is_adding;
};
bool operator < (event_t const & a, event_t const & b) {
    return not (make_pair(a.time, a.is_adding) < make_pair(b.time, b.is_adding)); // reversed
}
int main() {
    while (true) {
        int n; cin >> n;
        if (not n) break;
        priority_queue<event_t> q;
        for (int i = 0; i < n; ++i) {
            hms_t a, b;
            scanf("%d:%d:%d", &a.h, &a.m, &a.s);
            scanf("%d:%d:%d", &b.h, &b.m, &b.s);
            q.push({ a, i,  true });
            q.push({ b, i, false });
        }
        int result = 0;
        set<int> trains;
        while (not q.empty()) {
            event_t e = q.top(); q.pop();
            if (trains.count(e.train)) {
                trains.erase(e.train);
            } else {
                trains.insert(e.train);
                result = max(result, (int)trains.size());
            }
        }
        cout << result << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int toTime(int, int, int);

int main() {
  int n;
  while(cin >> n, n) {
    vector<pair<int, bool> > ts; // *, true : start, *, false : end
    for(int i = 0; i < n; ++i) {
      int h, m, s;
      char c, d;
      cin >> h >> c >> m >> d >> s;
      int st = toTime(h, m, s);
      ts.push_back(make_pair(st, true));
      cin >> h >> c >> m >> d >> s;
      int et = toTime(h, m, s);
      ts.push_back(make_pair(et, false));
    }
    sort(begin(ts), end(ts));
    int nnt = 0, maxnnt = 0;
    for(int i = 0; i < ts.size(); ++i) {
      nnt += ts[i].second * 2 - 1;
      if(i == ts.size() - 1 || ts[i].first != ts[i + 1].first) maxnnt = max(maxnnt, nnt);
    }
    cout << maxnnt << endl;
  }
  return 0;
}

int toTime(int h, int m, int s) {
  return h * 60 * 60 + m * 60 + s;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int stoi(string a){
	return (a[0]-'0')*10+a[1]-'0';
}
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P> > que;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		rep(i,n){
			string x,y;
			cin >> x >> y;
			int a=stoi(x.substr(0,2))*3600+stoi(x.substr(3,2))*60+stoi(x.substr(6,2));
			int b=stoi(y.substr(0,2))*3600+stoi(y.substr(3,2))*60+stoi(y.substr(6,2));
			que.push(P(b,0));
			que.push(P(a,1));
		}
		int now=0,ans=0;
		while(!que.empty()){
			P q=que.top();
			que.pop();
			if(q.second==0) now++;
			else{
				if(now>0) now--;
				else ans++;
			}
		}
		cout << ans << endl;
	}
}

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

#define mk(x, y) make_pair(x, y)
#define X first
#define Y second
#define SEC(h, m, s) (h * 3600 + m * 60 + s)

using namespace std;

typedef pair<int, int> pii;


int main( void )
{
	int T[10000];
	int n;
	while(cin >> n, n) {
		fill(T, T+n, 0);
		int ans = 0;
		for(int i=0; i < n; ++i) {
			int h1, m1, s1, h2, m2, s2;
			int ss1, ss2;
			scanf("%d:%d:%d", &h1, &m1, &s1);
			scanf("%d:%d:%d", &h2, &m2, &s2);
			ss1 = SEC(h1, m1, s1);
			ss2 = SEC(h2, m2, s2);
			for(int j=0; j < n; ++j) {
				if(T[j] <= ss1) {
					T[j] = ss2;
					ans = max(ans, j+1);
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}