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>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

int t1[20000];
int t2[20000];
bool used[20000];
int n;

void solve(int t) {
  int mini = -1;
  int min = 1000000;
  for(int i = 0; i < n; ++i) {
    if( used[i] ) continue;
    if( t1[i] < t ) continue;
    if( min > t2[i] ) {
      min = t2[i];
      mini = i;
    }
  }
  if( mini != -1 ) {
    used[mini] = true;
    solve(min);
  }
  return;
}
  
int main() {

  for(;;) {
    int h1, m1, s1, h2, m2, s2;
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
      t1[i] = h1 * 3600 + m1 * 60 + s1;
      t2[i] = h2 * 3600 + m2 * 60 + s2;
    }
    for(int i = 0; i < n; ++i) used[i] = false;
    int res = 0;
    for(int i = 0; i < n; ++i) {
      if( not used[i] ) {
        solve(0);
        res += 1;
      }
    }
    std::cout << res << std::endl;
  }      
    
  return 0;
}

C++: #pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 998244353
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int go[25][61][61];
int back[25][61][61];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    while(n){

        memset(go,0,sizeof(go));
        memset(back,0,sizeof(back));
        for(int i=0;i<n;i++){
            string s1,s2;cin>>s1>>s2;
            string a=s1.substr(0,2);
            string b=s1.substr(3,2);
            string c=s1.substr(6,2);
            go[stoi(a)][stoi(b)][stoi(c)]++;
            string aa=s2.substr(0,2);
            string bb=s2.substr(3,2);
            string cc=s2.substr(6,2);
            back[stoi(aa)][stoi(bb)][stoi(cc)]++;
        }
        int ans=1;int wehave=1;
        for(int i=0;i<24;i++){
            for(int j=0;j<60;j++){
                for(int k=0;k<60;k++){
                    if(back[i][j][k]){
                        wehave+=back[i][j][k];
                    }
                    if(go[i][j][k]){
                        if(go[i][j][k]>wehave){
                            ans+=go[i][j][k]-wehave;
                            wehave=0;
                        }
                        else{
                            wehave-=go[i][j][k];
                        }
                    }
                }
            }
        }
        cout<<ans<<endl;
        cin>>n;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

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

int main(){
  int n,h,m,s,time,ans,cnt;
  char q;
  vector<pair<int,int> > ti;
  while(1){
    cin>>n;
    ans=0,cnt=0;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>h>>q>>m>>q>>s;
      time=h*3600+m*60+s;
      ti.push_back(make_pair(time,1));
      cin>>h>>q>>m>>q>>s;
      time=h*3600+m*60+s;
      ti.push_back(make_pair(time,-1));
    }
    sort(ti.begin(),ti.end());
    for(int i=0;i<ti.size();i++)cnt+=ti[i].second,ans=max(cnt,ans);
    cout<<ans<<endl;
    ti.clear();
  }
  return 0;
}