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> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        int start[n],end[n];
        for(int i=0;i<n;i++){
            string in;
            cin>>in;
            string works=in.substr(0,2);
            works+=in.substr(3,2);
            works+=in.substr(6,2);
            istringstream work(works);
            work>>start[i];
            cin>>in;
            works=in.substr(0,2);
            works+=in.substr(3,2);
            works+=in.substr(6,2);
            istringstream work2(works);
            work2>>end[i];
        }
        int sum=1;
        int big=1;
        int kese=0;
        bool sw[n];
        for(int i=0;i<n;i++)sw[i]=0;
        for(int i=1;i<n;i++){//二項目から
            if(end[kese]<=start[i]){
                if(big>sum){
                    sum=big;
                    big=1;
                }
                kese=i;
                continue;
            }else{
                big++;
            }
        }
        cout<<big<<endl;
    }
    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 main() {
	cin.tie(0);

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

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

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

		int ans = 0, tmp = 0;
		rep(i,0,vp.size()) {
			tmp += vp[i].second;
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}

	return 0;
}

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

using i64 = int64_t;

int imos[100000]={0};

void init(){
    for(int i=0;i<100000;++i)imos[i] = 0;
}

int main(){
    int n;
    while(cin >> n, n != 0){
        init();
        for(int i=0;i<n;++i){
            int sh, sm, ss, eh, em, es;
            scanf("%d:%d:%d %d:%d:%d",&sh,&sm,&ss,&eh,&em,&es);
            imos[sh*3600+sm*60+ss]++;
            imos[eh*3600+em*60+es]--;
        }
        int cnt = 0, ans = 0;
        for(int i=0;i<=86399;++i){
            cnt += imos[i];
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }

    return 0;
}

C++: //#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
#include<sstream>

  using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)


typedef pair<ll,ll> pii;

bool comp(const pii l,const pii r){
  return l.second==r.second ? l.first<r.first : l.second<r.second;
}

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

    vector<pii> input(n);
    rep(i,n){
      string s,e;cin>>s>>e;
      pii train;
      const char *s_char = s.c_str();
      const char *e_char = e.c_str();
      ll hour,minute,second;
      sscanf(s_char, "%lld:%lld:%lld",&hour,&minute,&second);
      train.second=hour*60*60+minute*60+second;
      sscanf(e_char, "%lld:%lld:%lld",&hour,&minute,&second);
      train.first=hour*60*60+minute*60+second;
      input[i]=train;
    }
    
    sort(all(input),comp);
    
    priority_queue<pii> que;
    ll ans=0;
    rep(i,n){
      pii train=input[i];

      while(que.size()>0 && train.second>=que.top().first){
        que.pop();
      }
      que.push(train);
      ans=max(ans,(ll)que.size());
    }
    cout<<ans<<endl;
  }
  
  return 0;
}