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 <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

struct TimeStamp {
	int h, m, s;
	bool operator<(const TimeStamp &ts) const {
		if(h < ts.h){ return true; }
		if(h > ts.h){ return false; }
		if(m < ts.m){ return true; }
		if(m > ts.m){ return false; }
		return s < ts.s;
	}
};

typedef pair<TimeStamp, TimeStamp> ptt;
typedef pair<TimeStamp, int> pti;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<ptt> t(n);
		priority_queue< pti, vector<pti>, greater<pti> > pq;
		for(int i = 0; i < n; ++i){
			cin >> t[i].first.h; cin.ignore();
			cin >> t[i].first.m; cin.ignore();
			cin >> t[i].first.s;
			cin >> t[i].second.h; cin.ignore();
			cin >> t[i].second.m; cin.ignore();
			cin >> t[i].second.s;
			pq.push(pti(t[i].first, i));
		}
		int pool = 0, answer = 0;
		while(!pq.empty()){
			pti p = pq.top();
			pq.pop();
			if(p.second < 0){
				++pool;
			}else{
				pq.push(pti(t[p.second].second, -1));
				if(pool == 0){
					++answer;
				}else{
					--pool;
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAX = 24 * 60 * 60 + 60 * 60 + 60 + 1;
int f(int h, int m, int s) {
  return h * 3600 + m * 60 + s;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int imos[MAX];
  while(cin>>n,n) {
    int ans = 0;
    CLR(imos);
    FOR(i,0,n) {
      int h1, m1, s1;
      int h2, m2, s2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
      imos[f(h1,m1,s1)]++;
      imos[f(h2,m2,s2)]--;
    }
    FOR(i,0,MAX-1) {
      imos[i+1] += imos[i];
      ans = max(ans, imos[i+1]);
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
ll sum[100100];

int main() {
	while (cin >> n&&n) {
		fill(sum, sum + 100100, 0);
		REP(i, n) {
			char c;
			int h, m, s;
			cin >> h >> c >> m >> c >> s;
			sum[h * 60 * 60 + m * 60 + s]++;
			cin >> h >> c >> m >> c >> s;
			sum[h * 60 * 60 + m * 60 + s]--;
		}
		ll ans = 1;
		REP(i, 100100) {
			sum[i + 1] += sum[i];
			ans = max(ans, max(sum[i + 1], sum[i]));
		}
		cout << ans << endl;
	}
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int T=86400;

int main(){
  int n;
  while(cin>>n){
    if(n==0) return 0;
    
    vector<int> A(T+1);
    int h,m,s;
    char c;
    rep(i,n){
      cin>>h>>c>>m>>c>>s;
      A[3600*h+60*m+s]++;
      cin>>h>>c>>m>>c>>s;
      A[3600*h+60*m+s]--;
    }   
    
    for(int i=1;i<=T;i++){
     A[i]+=A[i-1];
    }
    
    int max=0;
    rep(i,T){
      if(max<A[i]) max=A[i];
    }    
    cout<<max<<endl;    
  }
  
  return 0;
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem2013 : Osaki **/
int MAX = 100000;

int toInt(string s)
{
	int h = (s[0]-'0')*10+s[1]-'0';
	int m = (s[3]-'0')*10+s[4]-'0';
	int se = (s[6]-'0')*10+s[7]-'0';
	
	return h*3600 + m*60 + se;
}

int main()
{
	int N;
	while (cin>>N, N) {
		vector<int> table(MAX);
		string a, b;
		rep(i, N) {
			cin>>a>>b;
			table[toInt(a)]++;
			table[toInt(b)]--;
		}
		
		REP(i, 1, MAX) {
			table[i] += table[i-1];
		}
		
		int ans=0;
		rep(i, MAX) {
			ans = max(ans, table[i]);
		}
		
		cout << ans << endl;
	}
}