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<cstdio>
#include<utility>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int n,h,m,s;
  while(scanf("%d",&n),n){
    vector< pair<int,int> > v;
    for(int i=0;i<n;i++){
      scanf("%d:%d:%d",&h,&m,&s);
      v.push_back(make_pair(h*3600 + m*60 + s,1));

      scanf("%d:%d:%d",&h,&m,&s);
      v.push_back(make_pair(h*3600 + m*60 + s,0));
    }

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

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

    printf("%d\n",ans);
  }
}

C++: #include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef struct Time{
  int h;
  int m;
  int s;
}Time;
typedef pair<int,int> pii;
int main(){
  int n;
  Time s[10000],e[10000];
  vector<pii>::iterator ite;
  vector<pii> train; 
  while(cin>>n,n){
    train.clear();
    int ans=0,sum=0;
    for(int i = 0;i < n;i++){
      scanf("%d:%d:%d %d:%d:%d",&s[i].h,&s[i].m,&s[i].s,&e[i].h,&e[i].m,&e[i].s);
      train.push_back(pii(s[i].h*3600 + s[i].m*60 + s[i].s,1)); 
      train.push_back(pii(e[i].h*3600 + e[i].m*60 + e[i].s,0));
    }
    sort(train.begin(),train.end());
    ite = train.begin();
    while(ite != train.end()){
      if(ite->second == 1){
	sum++;
	ans=max(ans,sum);
      }else{
	sum--;
      }
      ite++;
    }
    cout<<ans<<endl;
  }
}

C++: #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 500020;
const double pi = acos(-1); const double EPS = 1e-8;
const ll INF = 1e12;


int calc(string s) {
	int ans = 0;
	ans += 36000 * (s[0] - '0');
	ans += 3600 * (s[1] - '0');
	ans += 600 * (s[3] - '0');
	ans += 60 * (s[4] - '0');
	ans += 10 * (s[6] - '0');
	ans += (s[7] - '0');
	//pe(s); cout << ":" << ans << endl;
	return ans;
}
void solve() {
	int N; cin >> N;
	if (N == 0)exit(0);
	vector<P>v;
	REP(i, N) {
		string S, T; cin >> S >> T;
		//pe(S); print(T);
		int l = calc(S), r = calc(T);
		v.push_back({ l,r });
	}
	VSORT(v);
	priority_queue<int,vector<int>,greater<int>>que;
	int ans = 0;
	REP(i, N) {
		int r = v[i].second, l = v[i].first;
		while (!que.empty()) {
			if (que.top() <= l)que.pop();
			else break;
		}
		chmax(ans, que.size() + 1);
		que.push(r);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)

	while(true)
	solve();
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define DEBUG
const int N = 60 * 60 * 24 + 100;

int convert(string s){
  return (atoi(s.substr(0, 2).c_str()) * 60 * 60) + (atoi(s.substr(3, 2).c_str()) * 60) + atoi(s.substr(6, 2).c_str());
}

int main() {
  int n;
  while(cin >>n && n){
    vector<int> v(N, 0);
    REP(i, n){
      string s, e; cin >>s >>e;
      v[convert(s)] += 1;
      v[convert(e)] -= 1;
    }
    int ans = v[0];
    FOR(i, 1, N){
      v[i] += v[i - 1];
      ans = max(ans, v[i]);
    }
    cout <<ans <<endl;
  }
  return 0;
}