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 rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

void solve() {
    int n;
    cin >> n;
    if(n == 0) exit(0);
    vector<pii> a(n);
    auto calc = [&](const string& s) {
        int ret = 0;
        rep(i, s.size()) if(s[i] != ':') {
            ret *= 10;
            ret += s[i] - '0';
        }
        return ret;
    };
    rep(i, n) {
        string s, t;
        cin >> s >> t;
        a[i].fi = calc(s);
        a[i].se = calc(t);
    }
    sort(all(a));
    int ans = 1;
    multiset<int> st;
    st.insert(a[0].se);
    REP(i, 1, n) {
        auto it = st.upper_bound(a[i].fi);
        if(it == st.begin()) ans++;
        else st.erase(--it);
        st.insert(a[i].se);
    }
    cout << ans << '\n';
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) solve();
    return 0;
}

C++: #include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,a,b,c,d,e,f,ma=0;
  while(1){
    cin >> N;
    if(!N)
      return 0;
    vector<int> memo(1000000,0);
    ma = 0;
    REP(i,N){
      scanf("%d:%d:%d %d:%d:%d",&a,&b,&c,&d,&e,&f);
      memo[a*10000+b*100+c]++;
      memo[d*10000+e*100+f]--;
    }
    for(int i=1;i<memo.size();i++){
      memo[i] += memo[i-1];
      ma = max(ma,memo[i]);
    }
    cout << ma << endl;
  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  vector<int> ary(24*60*60,0);
  int n;
  while(cin>>n,n){
    char b[9],e[9];
    while(n--){
      cin>>b>>e;
      int h,m,s;
      sscanf(b,"%d:%d:%d",&h,&m,&s);
      int start = ((h * 60) + m) * 60 + s; 
      sscanf(e,"%d:%d:%d",&h,&m,&s);
      int finish = ((h * 60) + m) * 60 + s; 
      for(int i = start ; i < finish ; i ++)ary[i]++;
    }
    int ret = -1;
    for(int i = 0 ; i < ary.size() ; i ++)ret = max(ret,ary[i]);
    cout<<ret<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using P = pair<int,int>;

int main(){
    int n;
    while(cin>>n,n){
        vector<P> V;
        V.clear();
        for(int i=0;i<n;i++){
            int hh,mm,ss;
            cin>>hh;
            cin.ignore();
            cin>>mm;
            cin.ignore();
            cin>>ss;
            cin.ignore();
            int ts = hh*3600+mm*60+ss;
            V.emplace_back(ts,+1);
            cin>>hh;
            cin.ignore();
            cin>>mm;
            cin.ignore();
            cin>>ss;
            cin.ignore();
            int te = hh*3600+mm*60+ss;
            V.emplace_back(te,-1);
        }
        sort(V.begin(), V.end());
        int ans=0,cnt=0;
        for(auto v:V){
            cnt+=v.second;
            //cout<<cnt<<endl;
            ans=max(ans,cnt);
        }
        cout<<ans<<endl;
    }
    return 0;
}