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>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n;
int add[24*60*60+10];

void solve() {
    rep(i,24*60*60+5) add[i]=0;
    
    rep(i,n) {
        int s1,s2,s3;
        int t1,t2,t3;
        scanf("%d:%d:%d",&s1,&s2,&s3);
        scanf("%d:%d:%d",&t1,&t2,&t3);

        add[s1*60*60+s2*60+s3] += 1;
        add[t1*60*60+t2*60+t3] += -1;
    }
    rep(i,24*60*60+5) {
        add[i+1]+=add[i];
    }

    int ans=0;
    rep(i,24*60*60+5) {
        ans=max(ans,add[i]);
    }
    cout<<ans<<endl;

    

}

int main() {
    while(cin>>n) {
        if(!n) return 0;
        solve();
    }

    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
//int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	int n;
	const int MAX=10010;
	while(1){
		int ans_1[MAX],ans_2[MAX],cnt=0,ans=0;
		cin>>n;
		if(n==0)break;
		string s;
		rep(i,0,n){
			cin>>s;
			ans_1[i]=(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
			cin>>s;
			ans_2[i]==(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
		}
		int a[90000]={};
		rep(i,0,n)a[ans_1[i]]++,a[ans_2[i]]--;
		rep(i,0,90000)if(a[i]!=0)cnt+=a[i],ans=max(ans,cnt);
		print(ans);
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;
vector<P> t;

bool comp(P a,P b){
	if(a.first > b.first) return true;
	else if(a.first == b.first && a.second < b.second) return true;
	return false;
}

int main(){
	int n,h,m,s,ar,check;
	while(scanf("%d",&n),n){
		t.clear();
		ar = check = 0;
		for(int i = 0;i < n;++i){
			for(int j = 0;j < 2;++j){
				scanf("%d:%d:%d",&h,&m,&s);
				t.push_back(make_pair(h * 3600 + m * 60 + s, j));
			}
		}
		sort(t.begin(),t.end(),comp);
		reverse(t.begin(),t.end());
		vector<P>::iterator vit = t.begin();
		for(;vit != t.end();++vit){
			if((*vit).second == 0){
				if(ar == 0) ++check;
				else --ar;
			}
			else ++ar;
		}
		printf("%d\n",check);
	}
}

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


int main(){
    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<int> S(n), T(n);
        vector<int> table(3600*24, 0);
        for(int i=0; i<n; i++){
            for(int j=0; j<2; j++){
                string time; cin >> time;
                int hh, mm, ss;
                hh=10*(time[0]-'0')+(time[1]-'0');
                mm=10*(time[3]-'0')+(time[4]-'0');
                ss=10*(time[6]-'0')+(time[7]-'0');
                if(j == 0) S[i]=3600*hh+60*mm+ss;
                else T[i]=3600*hh+60*mm+ss;
            }
            table[S[i]]++;
            table[T[i]]--;
        }
        for(int i=1; i<3600*24; i++){
            table[i]+=table[i-1];
        }
        int res=0;
        for(int i=0; i<3600*24; i++){
            res=max(res, table[i]);
        }
        cout << res << endl;
    }
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, ans, k;
  string s, t;
  vector< pair<string, int> > T;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      cin >> s >> t;
      T.push_back(make_pair(s, 1));
      T.push_back(make_pair(t, -1));
    }
    ans = 0;
    k = 0;
    sort(T.begin(), T.end());
    for (int i = 0; i < 2*n; ++i) {
      k += T[i].second;
      ans = max(ans, k);
    }
    cout << ans << endl;
    T.erase(T.begin(), T.end());
  }
  return 0;
}

C++: #include <iostream>
using namespace std;

#define MAX 24*60*60

int main(){

  int train[MAX];
  int N;

  while(1){

    cin >> N;
    if(N == 0) break;
    int ans = 0;
    for(int i = 0 ; i < MAX ; i++){
      train[i] = 0;
    }    

    int h1,m1,s1,h2,m2,s2;
    char tmp;

    for(int i = 0; i < N ; i++){
    
      cin  >> h1 >> tmp >> m1 >> tmp >> s1 >> h2 >> tmp >> m2 >> tmp >> s2;
      //  cout << h1 << " " << m1 << " " << s1 << " " << h2 << " " << m2 << " " << s2 << endl;
      // cout   << train[3*60*60 +1] << " " << train[3*60*60] << endl;


      //テ・ツ按療ィツサツ甘」ツつ津・ツ「ツ療」ツつ?」ツ?凖」ツ?ィテ」ツ??

      bool OK = true;
      for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	if(train[i] == 0){
	  OK = false;
	  break;
	}
      }  
      
      if(OK == false){
	ans++;
	for(int i = 0 ; i < s1 + 60*m1 + 60*60*h1 ;i++){
	  train[i]++;
	} 
	for(int i = s2 + 60*m2 + 60*60*h2 ; i < MAX ;i++){
	  train[i]++;
	} 
      } 
      //ティツカツウテ」ツつ甘」ツ?ヲテ」ツ??」ツつ凝」ツ?ィテ」ツ??
      else{
	for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	  if(train[i] != 0) train[i]--;
	} 
      }
      //   cout << train[0] <<" "<< train[MAX-1] << endl;
    }
    cout << ans << endl;
  }  
  return 0;
}