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
//------------------------------------------
#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=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);

    	}
    	int ans =0;
    	bool used[100001]={false};
    	for(int i =0;i< dia.size();i++){
    		if(used[i] == false){
    			ans += 1;
                int now = dia[i].second;
                used[i] = true;
                for(int j =i+1;j < dia.size();j++){
                    if(used[j]== false&&now <= dia[j].first){
                        now = dia[j].second;
                        used[j] = true;
                    }
                }
    		
    		}
    	}
    	cout << ans << endl;
    }
}/*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);
                        }
*/

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 << tmp << m2 << tmp << s2 <<endl;

      //列車を増やすとき
      if(train[s1 + 60*m1 + 60*60*h1] <= 0){
	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 << ans << endl;
  }  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<pair<string,bool> >v;
    string a,b;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      v.push_back(make_pair(a,1));
      v.push_back(make_pair(b,0));
    }
    sort(v.begin(),v.end());
    int ans=0,k=0;
    for(int i=0;i<v.size();i++){
	if(v[i].second)k++;
	else k--;
	ans=max(k,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
  int n,h,m,s;
  char str;
  int temp;

  while(1){
    int t[86401]={0};
    int max=t[0];
    cin>>n;
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin>>h>>str>>m>>str>>s;
      temp=h*3600+m*60+s;
      t[temp]+=1;
      cin>>h>>str>>m>>str>>s;
      temp=h*3600+m*60+s;
      t[temp]+=-1;
    }
    
    for(int i=1;i<=86400;i++){
      t[i]+=t[i-1];
      if(max<=t[i])
        max=t[i];
    }

    cout<<max<<endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  vector<pair<int,int> > vec;
  
  scanf("%d",&n);

  if(n == 0) return false;


  for(int i=0;i<n;i++){
    int sh,sm,ss,eh,em,es;
    int s,e;

    scanf("%d:%d:%d %d:%d:%d",&sh,&sm,&ss,&eh,&em,&es);

    s = sh*3600 + sm+60 + ss;
    e = eh*3600 + em+60 + es;

    vec.push_back({s,e});
  }

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

  int ans = 0;
  int c = 0;

  int last = -1;
  
  for(int i=0;i<n;i++){
    if(last <= vec[i].first){
      ans = max(c,ans);
      c = 0;
    }
    c++;
    last = vec[i].second;
  }

  printf("%d\n",max(c,ans));

  return true;
}


int main(){

  while(solve());
  
  return 0;
}