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++: //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(!n) break;
        vi a(n), b(n);
        rep(i, n) {
            int g, h, j, l, p, o;
            scanf("%d:%d:%d %d:%d:%d", &g, &h, &j, &l, &p, &o);
            a[i] = g*3600 + h*60 + j;
            b[i] = l*3600 + p*60 + o;
        }

        vi ch(24*3600+1);
        rep(i, n) {
            ch[a[i]]++;
            ch[b[i]]--;
        }

        int ans = 0;
        int now = 0;
        rep(i, 24*3600+1) {
            now += ch[i];
            ans = max(ans, now);
        }

        cout << ans << '\n';
    }
}

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

using namespace std;
const int MAX = 100000;
typedef pair<int,int> P;
int ans[MAX];

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

void init(){
  fill(ans,ans+MAX,0);
}

int main(){
  int n;
  while(cin >> n && n){
    init();
    for(int i = 0; i < n; i++){
      int hh,ss,mm;
      int hh2,ss2,mm2;
      scanf("%d:%d:%d",&hh,&mm,&ss);
      scanf("%d:%d:%d",&hh2,&mm2,&ss2);
      int from = ToS(hh,mm,ss);
      int to = ToS(hh2,mm2,ss2);
      for(int i = from; i < to; i++)
	ans[i]++;
    }
    
    int out = 0;
    for(int i = 0; i < MAX; i++)
      out = max(out,ans[i]);

    cout << out << endl;

  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,h,m,s;
  while(scanf("%d",&n), n){
    vector<pii> event;

    for(int i=0;i<n;i++){
      scanf("%d:%d:%d",&h,&m,&s);
      event.push_back(pii(h*3600 + m*60 + s, 1));
      scanf("%d:%d:%d",&h,&m,&s);
      event.push_back(pii(h*3600 + m*60 + s, -1));
    }

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

    int cnt = 0, ans = 0;
    for(int i=0;i<(int)event.size();i++){
      cnt += event[i].second;
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }
}

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++: #pragma warning(disable:4996)

#include<cstdio>
#include<iostream>
#include <algorithm>
using namespace std;

#define rep(i,n) for (int i=0; i< (n); i++)

int n;
int imos[86400];

void solve() {
	rep(i, n) {
		int s[3];
		int t[3];

		scanf("%d : %d : %d", &s[0], &s[1], &s[2]);
		scanf("%d : %d : %d", &t[0], &t[1], &t[2]);

		//hh:mm:ss を秒に変換
		int S = s[2] + 60 * (s[1] + s[0] * 60);
		int T = t[2] + 60 * (t[1] + t[0] * 60);

		//
		imos[S]++;

		imos[T]--;
	}
	rep(i, 86400) if (i) imos[i] += imos[i - 1];

	int ans = 0;
	rep(i, 86400) ans = max(ans, imos[i]);

	cout << ans << endl;
}

int main() {
	while (cin >> n, n) {
		rep(i, 86400)  imos[i] = 0;
		solve();
	}
}