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

using namespace std;

bool dabu(int a, int b,int a1,int b1){
	if (a1>=b)return 0;
	if (b1<=a)return 0;
	return 1;
}

int main(){
	int n;
	vector<vector<int>>jikoku(10000,vector<int>(2));
	while (cin >> n, n){
		int ans=1;
		int ans1 = 1;
		for (int i = 0; i < n; i++){
			int si, shu;
			int  si1, si2, si3, shu1, shu2, shu3;
			scanf_s("%d:%d:%d %d:%d:%d", &si1, &si2, &si3, &shu1, &shu2, &shu3);
			si = 3600 * si1 + 60 * si2 + si3;
			shu = 3600 * shu1 + 60 * shu2 + shu3;
			jikoku[i][0]=si;
			jikoku[i][1]=shu;
			if (i){
				ans = 1;
				for (int j=0; j < i; j++){
					ans += dabu(jikoku[j][0], jikoku[j][1], si, shu);
				}
			}
			ans1 = max(ans, ans1);
		}
		cout << ans1 << endl;
	}
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Count[86401], h, m, s;

int Solve(){
  fill(Count, Count + 86400, 0);
  for (int i = 0; i < N; i++){
    scanf("%d:%d:%d", &h, &m, &s);
    int now = h * 3600 + m * 60 + s;
    Count[now]++;
    scanf("%d:%d:%d", &h, &m, &s);
    now = h * 3600 + m * 60 + s;
    Count[now]--;
  }

  int ans = Count[0];
  for (int i = 1; i < 86400; i++){
    Count[i] += Count[i - 1];
    ans = max(ans, Count[i]);
  }
  printf("%d\n", ans);

  return 0;
}

int main(){
  while (cin >> N){
    if (N == 0) return 0;
    else Solve();
  }

  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    while (true) {
        ll n;
        cin >> n;
        if (n == 0) return;
        vector<ll> range(86405, 0);
        rep(i, n) {
            string s, t;
            cin >> s >> t;
            ll s1 = 0, s2 = 0;
            s1 = stoll(s.substr(0, 2)) * 3600 + stoll(s.substr(3, 2)) * 60 +
                 stoll(s.substr(6, 2));
            s2 = stoll(t.substr(0, 2)) * 3600 + stoll(t.substr(3, 2)) * 60 +
                 stoll(t.substr(6, 2));
            range[s2]--;
            range[s1]++;
        }
        rep(i, 86403) {
            range[i + 1] += range[i];
        }
        cout << *max_element(range.begin(), range.end()) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    // ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

C++: #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int t[87000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;

		memset(t,0,sizeof(t));
		rep(i,0,n) {
			int h,m,s;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]++;
			scanf("%d:%d:%d", &h, &m, &s);
			t[h*3600 + m*60 + s]--;
		}

		int ans = -1, tmp = 0;
		rep(i,0,87000) {
			tmp += t[i];
			if(ans < tmp) ans = tmp;
		}
		cout << ans << endl;
	}

	return 0;
}