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<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
typedef pair<double,double>d_d;
#define inf 100000000//10^8

/////////////////////////////////




int main(){
    int n;
    while(cin>>n,n){
        int a[60*60*24+5];
        memset(a,0,sizeof(a));
        for(int i=0;i<=2*n-1;i++){
            int h,m,s;scanf("%d:%d:%d",&h,&m,&s);
            
            if(i%2==0)a[s+60*m+3600*h]++;
            else a[s+60*m+3600*h]--;
        }
        for(int i=1;i<=60*60*24+1;i++){
            a[i]+=a[i-1];
        }
        int max=0;
        for(int i=0;i<=60*60*24+1;i++){
            if(a[i]>max)max=a[i];
        }
        cout<<max<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi v(100005,0);
    rep(i,n){
      int a,b,c;
      scanf("%d:%d:%d",&a,&b,&c);
      v[a*3600+b*60+c]++;
      scanf("%d:%d:%d",&a,&b,&c);
      v[a*3600+b*60+c]--;
    }
    rep(i,100000)v[i+1]+=v[i];
    int ans=0;
    rep(i,100000)ans=max(ans,v[i]);
    cout<<ans<<endl;
  }
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 55
#define MAX (1LL << 31) -1
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
//#define F function<T(T,T)>

int f(string s){
    return stoi(s.substr(0,2))*3600+stoi(s.substr(3,2))*60+stoi(s.substr(6,2));
}

signed main(){
    while(true){
        int n;
        cin>>n;
        if(n==0) return 0;
        vector<P> V;
        for(int i=0;i<n;i++){
            string s,t;
            cin>>s>>t;
            V.emplace_back(f(s),f(t));
        }
        sort(V.begin(),V.end());
        multiset<int> S;
        S.insert(MAX);
        S.insert(-1);
        int count=0;
        for(int i=0;i<n;i++){
            int x=V[i].first;
            auto it=S.upper_bound(x);
            it--;
            if(*it==-1) count++;
            else S.erase(it);
            S.insert(V[i].second);
        }
        cout<<count<<endl;
    }
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXS = 24 * 60 * 60;

int n;
int imos[MAXS + 1];

int convert(string str){
    int hour = stoi(str.substr(0, 2));
    int min = stoi(str.substr(3, 2));
    int sec = stoi(str.substr(6, 2));
    // cout << hour << " " << min << " " << sec << endl;
    return hour * 60 * 60 + min * 60 + sec;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<=MAXS;i++){
            imos[i] = 0;
        }
        for(int i=0;i<n;i++){
            string str1, str2; cin >> str1 >> str2;
            int s = convert(str1);
            int t = convert(str2);
            imos[s]++;
            imos[t]--;
        }
        int ma = 0;
        for(int i=1;i<=MAXS;i++){
            imos[i] += imos[i-1];
            if(imos[i] > ma) ma = imos[i];
        }
        cout << ma << endl;
    }
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, dh, dm, ds, ah, am, as, dtime, atime;
  string dep, arr, num = "0123456789";
  while (cin >> n, n) {
    int cnt[24*60*60] = {0};
    while (n--) {
      cin >> dep >> arr;
      dh = (int)num.find(dep[0])*10 + (int)num.find(dep[1]);
      dm = (int)num.find(dep[3])*10 + (int)num.find(dep[4]);
      ds = (int)num.find(dep[6])*10 + (int)num.find(dep[7]);
      ah = (int)num.find(arr[0])*10 + (int)num.find(arr[1]);
      am = (int)num.find(arr[3])*10 + (int)num.find(arr[4]);
      as = (int)num.find(arr[6])*10 + (int)num.find(arr[7]);
      dtime = (dh*24+dm)*60+ds;
      atime = (ah*24+am)*60+as;
      for (int i = dtime; i < atime; i++) {
        cnt[i]++;
      }
    }
    int max = 0;
    for (int i = 0; i < 24*60*60; i++) {
      if (max < cnt[i]) {
        max = cnt[i];
      }
    }
    cout << max << el;
  }
}