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 <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int main() {
	int n;
	vector<PII> _array;
	while ( scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			int h, m, s;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].first = s + m * 60 + h * 3600;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].second = s + m * 60 + h * 3600;
		}
		sort( _array.begin(), _array.end() );
		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			bool is_add = true;
			for ( int j = 0; j < i; j++ ) {
				if ( _array[ i ].first >= _array[ j ].second ) {
					is_add = false;
					_array[ j ].second = INF;
					break;
				}
			}
			ans += is_add;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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;


bool lessP(const pair<int, int>& x, const pair<int, int>& y){
    return x.first < y.first;
}
int main(){
    int N=1;
    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);

    	}
	sort(dia.begin(),dia.end(),lessP);
    	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;
                        int a = used.size();
                        for(int l =0;l < a;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 <cstdio>
#include <algorithm>
using namespace std;

const int TIME = 60 * 60 * 20 + 60 * 60 + 60;
int data[TIME];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n && n != 0){
		for(int i = 0; i < TIME; ++i){
			data[i] = 0;
		}
		
		int a, b, c;
		for(int i = 0; i < n; ++i){
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] ++;
			
			scanf("%d:%d:%d", &a, &b, &c);
			data[a * 60 * 60 + b * 60 + c] --;
		}
	
		int ans = 0;
		for(int i = 0; i < TIME; ++i){
			if(i > 0)
				data[i] += data[i - 1];
			ans = max(ans, data[i]);
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>

using namespace std;
#define MP make_pair
typedef pair<int,int> PII;

int main(){
  int N;

  while(cin >> N, N){
	vector<PII> tm(N);
	for(int i=0;i<N;++i){
	  int h1, m1, s1, h2, m2, s2;
	  scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
	  tm[i].first = s1+m1*60+h1*60*60;
	  tm[i].second = s2+m2*60+h2*60*60;
	}
	sort(tm.begin(), tm.end());

	int ans = 0;
	for(int i=0;i<N;++i){
	  int sum = 1;
	  for(int j=i+1;j<N;++j){
		if(tm[i].first <= tm[j].first && tm[j].second <= tm[i].second)
		  ++sum;
		else
		  break;
	  }
	  ans = max(ans, sum);
	}
	cout << ans << endl;
  }
}