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 pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n,n){
    vector<pair<string,string>> s(n);
    rep(i,n){
      cin >> s[i].fi >> s[i].se;
    }
    int c = 1;
    sort(all(s));
    vector<string> t;
    t.push_back(s[0].se);
    rep(i,n-1){
      bool f = false;
      rep(j,t.size()){
        if(s[i+1].fi >= t[j]){
          f = true;
          t[j] = s[i+1].se;
          break;
        }
      }
      if(!f){
        ++c;
        t.push_back(s[i+1].se);
      }
    }
    std::cout << c << std::endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define M 1e7
using namespace std;
int main(){
	int n,i,j,b[6];
	while(cin>>n,n){
		int a[86400]={0},ans=0,c=0;
		while(n--){
			scanf("%d:%d:%d %d:%d:%d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
			a[b[0]*3600+b[1]*60+b[2]]++;
			a[b[3]*3600+b[4]*60+b[5]]--;
		}
		for(i=0;i<86400;i++){
			c+=a[i];
			ans=max(ans,c);
		}
		cout<<ans<<endl;
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int n;
int sum[300000];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(sum,0,sizeof(sum));
		for(int i=0;i<n;i++){
			int h,m,s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			sum[h*60*60+m*60+s]++;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			sum[h*60*60+m*60+s]--;
		}
		int res=sum[0];
		for(int i=0;i<=24*60*60;i++){
			sum[i+1]+=sum[i];
			res=max(res,sum[i+1]);
		}
		printf("%d\n",res);
	}
	return 0;

}

C++: #include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int n;

int f(char c){
    return (int)(c - '0');
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin >> n;
        if(n == 0) break;
        vector<int> imos(60*60*24+100, 0);
        
        REP(i, n){
            string s1, s2;
            cin >> s1 >> s2;
            int t1 = 0, t2 = 0;
            t1 += f(s1[0]) * 36000 + f(s1[1]) * 3600 + f(s1[3]) * 600 + f(s1[4]) * 60 + f(s1[6]) * 10 + f(s1[7]);
            t2 += f(s2[0]) * 36000 + f(s2[1]) * 3600 + f(s2[3]) * 600 + f(s2[4]) * 60 + f(s2[6]) * 10 + f(s2[7]);
            imos[t1]++; imos[t2]--;
        }
        REP(i, 60*60*24+10) imos[i+1] += imos[i];
        int ans = 0;
        
        REP(i, 60*60*24+1) ans = max(ans, imos[i]);
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <string.h>

using namespace std;
int table[90000];

void solve()
{
	int n;
	while(cin >> n, n)
	{
		memset(table, 0, sizeof(table));
		while(n--)
		{
			string str1, str2;
			cin >> str1 >> str2;
			int start, end;
			start = (str1[0] - '0') * 36000 + (str1[1] - '0') * 3600 + (str1[3] - '0') * 600 + (str1[4] - '0') * 60 + (str1[6] - '0') * 10 + (str1[7] - '0');
			end = (str2[0] - '0') * 36000 + (str2[1] - '0') * 3600 + (str2[3] - '0') * 600 + (str2[4] - '0') * 60 + (str2[6] - '0') * 10 + (str2[7] - '0');
			for(int i = start; i < end; ++i)
			{
				table[i]++;
			}
		}
		int max = 0;
		for(int i = 0; i < 90000; ++i)
		{
			if(max < table[i])
			{
				max = table[i];
			}
		}
		cout << max << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main(){
  int time[100000];

  int n;
  while(cin>>n,n!=0){
      memset(time,0,sizeof(time));
      for(int i = 0;i<n;i++){
	int h,m,s;
	scanf("%d:%d:%d",&h,&m,&s);
	time[h * (60*60) + m * 60 + s]++;
	scanf("%d:%d:%d",&h,&m,&s);
	time[h * (60*60) + m * 60 + s]--;
      }
      for(int i = 1;i<=24*60*60;i++){
	time[i] += time[i-1];
      }
      cout<<*max_element(time,time+24*60*60)<<endl;
  }

  return 0;
}