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;

typedef struct{
	int start,end;
	bool labelFlag;
}jikan;

int jikanShori(int h,int m,int s){
	return h*3600+m*60+s;
}

int main(){
	int n,cnt;
	int h,m,s;
	jikan interval[10000];
	
	for(int i=0;i<10000;i++){
		interval[i].start=0;
		interval[i].end=0;
		interval[i].labelFlag=false;
	}
	while(cin>>n,n){
		cnt=1;
		for(int i=0;i<10000;i++){
			interval[i].start=0;
			interval[i].end=0;
		}
		
		for(int i=0;i<n;i++){
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].start=jikanShori(h,m,s);
			scanf("%d:%d:%d",&h,&m,&s);
			interval[i].end=jikanShori(h,m,s);
		}
		
		for(int i=0;i<n;i++){
			if(!interval[i].labelFlag){
				interval[i].labelFlag=true;
				for(int j=i+1;j<n;j++){
					if(interval[i].end>interval[j].start && 
									!interval[j].labelFlag){
						cnt++;
						interval[j].labelFlag=true;
					}
				}
			}
		}
		
		cout<<cnt<<endl;
	}
}

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

int main()
{
  int n,a;
  for(;cin>>n,n;cout<<a<<endl)
    {
      int start[n];
      int end[n];
      char x;
      int h,m,s;
      for(int i=0;i<n;i++)
	{
	  cin>>h>>x>>m>>x>>s;
	  start[i]=(h*60+m)*60+s;
	  cin>>h>>x>>m>>x>>s;
	  end[i]=(h*60+m)*60+s;
	}
      sort(start,start+n);
      sort(end,end+n);
      a=0;
      int count=0;
      for(int s=0,e=0;s<n||e<n;a=max(count,a))
	  if(s>=n)
	    count--,e++;
	  else if(e>=n)
	    count++,s++;
	  else if(start[s]<end[e])
	    count++,s++;
	  else
	    count--,e++;
    }
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int HourtoMin(string s);

int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int time_s;
        string h_m_s;
        vector<pair<int, int> > trains(20001);
        for(int i = 0; i < 2 * n; i++){
            cin >> h_m_s;
            time_s = HourtoMin(h_m_s);
            if(i % 2 == 0) trains[i] = make_pair(time_s, 1);
            else trains[i] = make_pair(time_s, 0);
            // 到着したときは0、出発したときは1
        }
        sort(trains.begin(), trains.begin() + 2 * n);
        int osaki_now_train = 0, need_train = 0;
        for(int i = 0; i < 2 * n; i++){
            if(trains[i].second == 1){
                if(osaki_now_train == 0) need_train++;
                else osaki_now_train--;
            } else if(trains[i].second == 0) osaki_now_train++;
        }
        cout << need_train << endl;
    }
    return 0;
}

int HourtoMin(string s)
{
    int ans = 0;
    for(int i = 0; i <= 6; i = i + 3){
        ans += ((s[i] - '0') * 10 + s[i + 1] - '0') * (int)pow(60, ((6 - i) / 3));
    }
    return ans;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

const int T = 24 * 60 * 60;
int d[T];

int to_int(string s){
    int res = 0;
    res += ((s[0]-'0')*10 + s[1]-'0') * 3600;
    res += ((s[3]-'0')*10 + s[4]-'0') * 60;
    res += ((s[6]-'0')*10 + s[7]-'0');
    return res;
}

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N;
    while(cin>>N, N){
        memset(d, 0, sizeof(d));
        
        while(N--){
            string s, e;
            cin >> s >> e;
            d[to_int(s)]++;
            d[to_int(e)]--;
        }
        for(int i=1; i<T; i++)
            d[i] += d[i-1];
        
        int ans = 0;
        for(int i=0; i<T; i++)
            ans = max(ans, d[i]);
        
        cout << ans << endl;
    }
    
    return 0;
}

C++:  #define _USE_MATH_DEFINES
 #define INF 100000000
 #include <iostream>
 #include <cstdio>
 #include <sstream>
 #include <cmath>
 #include <cstdlib>
 #include <algorithm>
 #include <queue>
 #include <stack>
 #include <limits>
 #include <map>
 #include <string>
 #include <cstring>
 #include <set>
 #include <deque>
 #include <bitset>
 #include <list>

 using namespace std;

 typedef long long ll;
 typedef pair <int,int> P;

 static const double EPS = 1e-8;

int hour2second(int h,int m,int s){
  return h*60*60+m*60+s;
}

int main(){
   int n;
   while(~scanf("%d",&n)){
     if(n==0) break;

     vector<int> departure_times;
     vector<int> arrive_times;
     for(int i=0;i<n;i++){
       //hh:mm:ss hh:mm:ss 
       int hh[2],mm[2],ss[2];
       scanf("%d:%d:%d %d:%d:%d",
	     hh,mm,ss,hh+1,mm+1,ss+1);
       int departure_second = hour2second(hh[0],mm[0],ss[0]);
       int arrive_second = hour2second(hh[1],mm[1],ss[1]);

       departure_times.push_back(departure_second);
       arrive_times.push_back(arrive_second);
     }
     sort(departure_times.begin(),departure_times.end());
     sort(arrive_times.begin(),arrive_times.end());
     
     int dep_idx = 0;
     int res = 0;
     int count = 0;     
     for(int arv_idx=0;arv_idx<arrive_times.size();arv_idx++){
       while(dep_idx<departure_times.size()){
	 if(departure_times[dep_idx] < arrive_times[arv_idx]){
	   count++;
	   dep_idx++;
	   res = max(res,count);
	 }
	 else{
	   count--;
	   break;
	 }
       }
     }
     printf("%d\n",res);
   }
}