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 <vector>
using namespace std;

int main(){
    vector< vector<int> > trains;
    int n,i,j,k,f,t,h,m,s,flg;
    while(1){
        scanf("%d",&n);
        if(!n){break;}
        for(i=0;i<n;i++){
            scanf("%d:%d:%d",&h,&m,&s);
            f=h*3600+m*60+s;
            scanf("%d:%d:%d",&h,&m,&s);
            t=h*3600+m*60+s;
            if(trains.empty()){
                vector<int> buf(86401,0);
                for(j=f;j<=t;j++){buf[i]=1;}
                trains.push_back(buf);
            }
            else{
                for(auto itr=trains.begin();itr!=trains.end();itr++){
                    flg=0;
                    for(j=f+1;j<t;j++){if((*itr)[j]){flg=1;break;}} 
                    if(!flg){
                        for(j=f;j<=t;j++){(*itr)[j]=1;}
                        break;
                    }
                }
                if(flg){
                    vector<int> buf(86401,0);
                    for(j=f;j<=t;j++){buf[j]=1;}
                    trains.push_back(buf);
                }
            }
        }
        printf("%lu\n",trains.size());
    }
    return 0;
}

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

typedef pair<long long, long long> P;
void solve(int n){
	vector<int> v;
	vector<P> w;
	for(int i=0; i<n; ++i){
		int a, b, h, m, s;
		scanf("%d:%d:%d", &h, &m, &s);
		a = 3600*h + 60*m + s;
		scanf("%d:%d:%d", &h, &m, &s);
		b = 3600*h + 60*m + s;
		w.push_back(P(a, b));
	}
	sort(w.begin(), w.end());
	for(int i=0; i<n; ++i){
		int a = w[i].first;
		int b = w[i].second;
		bool f = false;
		for(int j=0; j<v.size(); ++j)
			if(v[j] <= a){
				v[j] = b;
				f = true;
				break;
			}
		if(!f) v.push_back(b);
		sort(v.begin(), v.end());
	}
	cout << v.size() << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}

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;
vector<pair<int, int>> v;
int main()
{
loop:
  int a, b, c, d, e, f;

  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++;
    q.push(v[i].second);
  }
  printf("%d\n", ans);
  goto loop;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int H = 60 * 60, M = 60, CHAKU = 0, HATU = 1;

typedef pair<int, int> pp;

int main()
{
    int n;
    while(cin >> n && n)
    {
        int ans = 0, h, m, s;
        char t;
        vector<pp> tr;
        REP(n)
        {
            cin >> h >> t >> m >> t >> s;
            tr.push_back(pp(h * H + m * M + s, HATU));
            cin >> h >> t >> m >> t >> s;
            tr.push_back(pp(h * H + m * M + s, CHAKU));
        }
        sort(all(tr));

        int num = 0;
        REP(n * 2)
            if(tr[i].second == CHAKU){ num--; ans = max(ans, num);}
            else { num++; ans = max(ans, num);}

        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;



int main(){

    int n;
    vector<pair<string,string>> v;
    int result;
    while(cin>>n,n){
        v.resize(n);
        REP(i,n){
            cin>>v[i].first>>v[i].second;
        }

        sort(v.begin(),v.end());
   
        priority_queue< string,std::vector<string>,greater<string>> pq;
        pq.push(v[0].second);
        result = 1;

        /*
        REP(i,n){
            cout << v[i].first << " " << v[i].second << endl;
        }*/

        FOR(i,1,n){
            if(pq.top().compare(v[i].first)<=0){
                pq.pop();
                
            }else{
                result++;
           
            }
            pq.push(v[i].second);
        }
        cout << result << endl;
    }
    

    return 0;
}