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 <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;


int main()
{
	int n;
	while(cin>>n,n){

		vector<long> t(24*3600+1,0);
		long res=0;

		for(int i=0;i<n;i++){
			string s;
			cin>>s;

			long a;
			a=((long)(s[0]-'0')*10+(long)(s[1]-'0'))*3600;
			a+=((long)(s[3]-'0')*10+(long)(s[4]-'0'))*60;
			a+=((long)(s[6]-'0')*10+(long)(s[7]-'0'));
			t[a]++;

			cin>>s;
			long b;
			b=((long)(s[0]-'0')*10+(long)(s[1]-'0'))*3600;
			b+=((long)(s[3]-'0')*10+(long)(s[4]-'0'))*60;
			b+=((long)(s[6]-'0')*10+(long)(s[7]-'0'));
			t[b]--;


		}

		for(long i=1;i<t.size();i++) t[i]+=t[i-1];
		for(long i=0;i<t.size();i++) res=max(res,t[i]);
		cout<<res<<endl;

	}

	return 0;
}

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

int main() {

  long long int n;

  while( true ) {

    cin >> n;
    if ( n == 0 ) break;

    vector< pair< long long int, long long int > > v;

    for ( long long int i = 0; i < n; i++ ) {

      long long int h, m, s;
      char c;

      cin >> h >> c >> m >> c >> s;
      v.push_back( make_pair( h * 60 * 60 + m * 60 + s, 1 ) );

      cin >> h >> c >> m >> c >> s;
      v.push_back( make_pair( h * 60 * 60 + m * 60 + s, 0 ) );

    }

    sort( v.begin(), v.end() );

    long long int ans = 0;
    long long int cnt = 0;

    for ( long long int i = 0; i < v.size(); i++ ) {

      if ( v[i].second == 0 ) {
	cnt--;
      }else {
	cnt++;
	ans = max( ans, cnt );
      }

    }

    cout << ans << endl;

  }

  return 0;

}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;
typedef std::vector<PII> VPII;

int n;
VPII v;
int main() {
    int h, m, s;
    while(std::cin >> n, n != 0) {
        v.clear();
        REP(i, n) {
            scanf("%d:%d:%d", &h, &m, &s);
            v.pb(mp(h*3600+m*60+s, 1));
            scanf("%d:%d:%d", &h, &m, &s);
            v.pb(mp(h*3600+m*60+s, -1));
        }
        SORT(v);

        int res = 0, ans = 0;
        for(auto t: v) {
            res += t.snd;
            ans = std::max(ans, res);
        }
        std::cout << ans << std::endl;
    }
}

C++: #include <algorithm>/*{{{*/
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define SZ(a) ((int)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define F first
#define S second
#define MP(a, b) make_pair(a, b)
#define BIT(n) (1ULL << (n))

static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

using namespace std;
typedef long long int LL;
typedef pair<int,int> P;/*}}}*/

int starts[24][60][60];
int arrivals[24][60][60];

int main(int argc, char const* argv[])
{
	int N;
	while (cin >> N, N) {
		FOR(i, 0, 24) {
			FOR(j, 0, 60) {
				FOR(k, 0, 60) {
					starts[i][j][k] = 0;
					arrivals[i][j][k] = 0;
				}
			}
		}
		FOR(i, 0, N) {
			int h, m, s;
			char buf;
			cin >> h >> buf >> m >> buf >> s;
			++starts[h][m][s];
			cin >> h >> buf >> m >> buf >> s;
			++arrivals[h][m][s];
		}

		int ans = 0;
		int stock = 0;
		FOR(i, 0, 24) {
			FOR(j, 0, 60) {
				FOR(k, 0, 60) {
					if (arrivals[i][j][k]) {
						//printf("arrive at %d:%d:%d\n", i, j, k);
						stock += arrivals[i][j][k];
					}
					if (starts[i][j][k]) {
						FOR(l, 0, starts[i][j][k]) {
							if (stock == 0) {
								++ans;
							} else {
								--stock;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}