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<queue>
#include<algorithm>
using namespace std;

int ss(int a, int b, int c)
{
  return a * 3600 + b * 60 + c;
}

int N;
int main()
{
loop:
  int a, b, c, d, e, f;
  vector<pair<int, int>> v;

  scanf("%d", &N);
  if(!N)
    return 0;
  for(int i = 0; i < N; i++)
  {
    scanf("%d:%d:%d %d:%d:%d", &a, &b, &c, &d, &e, &f);
    v.push_back(make_pair(ss(a, b, c), ss(d, e, f)));
  }

  int ans = 0, x = 0;
  priority_queue<int, vector<int>, greater<int>> q;
  q.push(1000000000);
  sort(v.begin(), v.end());
  for(int i = 0; i < v.size(); i++)
  {
    while(v[i].first >= q.top())
    {
      q.pop();
      x++;
    }
    if(!x)
      ans++;
    else
      x--;
    q.push(v[i].second);
  }
  printf("%d\n", ans);
  goto loop;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    while(cin >> N && N){

    	vector<pair<int,int> >dia;
    	for(int i =0;i< N;i++){
    		vector<string>ss;
    		string st;
    		cin >> st;
    		ss.push_back(st);
    		cin >> st;
    		ss.push_back(st);
    		pair<int,int>buf(0,0);
    		buf.first = (ss[0][0]*10+ss[0][1])*3600+(ss[0][3]*10+ss[0][4])*60+(ss[0][6]*10+ss[0][7]);
    		
    		buf.second = (ss[1][0]*10+ss[1][1])*3600+(ss[1][3]*10+ss[1][4])*60+(ss[1][6]*10+ss[1][7]);
    		dia.push_back(buf);

    	}
    	int ans =0;
    	vector<int>used;
    		for(int i =0;i< dia.size();i++){
    			bool us = true;
    			for(int j =0;j < used.size();j++){
    				if(i==used[j])us = false;
    			}
    			if(us){
    				ans +=1;
    				used.push_back(i);
    				int now=dia[i].second;
    				for(int k = i+1;k< dia.size();k++){
    					bool s = true;
                        for(int l =0;l < used.size();l++){
                            if(used[l] == k)s = false;
                        }
                        if(now <= dia[k].first && s){
    						now = dia[k].second;
    						used.push_back(k);
    					}
    				}
    			}
    		}
    	cout << ans << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<utility>
#include<cstdio>
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,i = 0;
    for(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++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3 - 1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;


int main() {
	int n;
	while (cin >> n, n) {
		vector<pii> times(2*n);
		string buf;
		REP(i,n)
			REP(j, 2) {
			cin >> buf;
			times[2 * i + j].first = stoi(buf.substr(0, 2)) * 60 * 60 + stoi(buf.substr(3, 2)) * 60 + stoi(buf.substr(6, 2));
			times[2 * i + j].second = j;
		}
		sort(ALL(times),
			[](pii lef, pii rig) {
			return lef.first < rig.first ||
				lef.first == rig.first && lef.second>rig.second;
		});
		int count = 0;
		int stopping = 0;
		REP(i, 2 * n) {
			if (times[i].second)
				stopping++;
			else if (stopping > 0)
				stopping--;
			else
				count++;
		}
		cout << count << endl;
	}
	return 0;
}