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++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int g(string S) {
    return (S[0] - '0')*10 + (S[1] - '0');
}
int f(string S) {
    int h = g(S.substr(0,2));
    int m = g(S.substr(3,2));
    int s = g(S.substr(6,2));
    return h*3600 + m*60 + s;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N; cin >> N;
        if (!N) break;
        vector<int> A(90000);
        rep(i,N) {
            string S,T; cin >> S >> T;
            int l = f(S);
            int r = f(T);
            A[l]++;
            A[r]--;
        }
        rep(i,88000) {
            A[i+1] += A[i];
        }
        cout << *max_element(all(A)) << ln;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int main() {
	int n;
	vector<PII> _array;
	while ( scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			int h, m, s;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].first = s + m * 60 + h * 3600;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].second = s + m * 60 + h * 3600;
		}
		sort( _array.begin(), _array.end() );
		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			bool is_add = true;
			for ( int j = 0; j < i; j++ ) {
				if ( _array[ i ].first >= _array[ j ].second ) {
					is_add = false;
					break;
				}
			}
			ans += is_add;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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

using namespace std;

//#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

constexpr int MAX = 100000;
int table[MAX];

inline int string_to_time(const string& str) {
    int h = str[0] - '0';
    h = h * 10 + (str[1] - '0');
    int m = str[3] - '0';
    m = m * 10 + (str[4] - '0');
    int s = str[6] - '0';
    s = s * 10 + (str[7] - '0');
    return h * 60 * 60 + m * 60 + s;
}

int main() {
    int n;
    string str;
    while (cin >> n, n) {
        for (int i = 0; i < MAX; ++i) {
            table[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
            cin >> str;
            const int start = string_to_time(str);
            table[start]++;
            cin >> str;
            const int end = string_to_time(str);
            table[end]--;
            dump(start);
            dump(table[start]);
            dump(end);
            dump(table[end]);
        }

        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < MAX; ++i) {
            tmp += table[i];
            ans = max(ans, tmp);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
#define MP make_pair
typedef pair<int,int> PII;

int main(){
  int N;

  while(cin >> N, N){
	vector<PII> tm(N);
	for(int i=0;i<N;++i){
	  int h1, m1, s1, h2, m2, s2;
	  scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
	  tm[i].first = s1+m1*60+h1*60*60;
	  tm[i].second = s2+m2*60+h2*60*60;
	}
	sort(tm.begin(), tm.end());

	int ans = 0;
	for(int i=0;i<N;){
	  int sum = 0;
	  int st = tm[i].first, et = tm[i].second;
	  while(i < N && tm[i].first < et){
		++sum;
		++i;
	  }
	  ans = max(ans, sum);
	}
	cout << ans << endl;
  }
}