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 <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
int main() {
  while(1){
    int n;
    cin >> n;
    if (!n) break;
    vector<int> v(86400);
    for (int i = 0; i < n; ++i) {
      int h[2],m[2],s[2];
      scanf("%d:%d:%d",&h[0],&m[0],&s[0]);
      scanf("%d:%d:%d",&h[1],&m[1],&s[1]);
      int bg = h[0]*3600 + m[0]*60 + s[0];
      int ed = h[1]*3600 + m[1]*60 + s[1];
      ++v[bg];
      --v[ed];
    }
    for (int i = 1; i < 86400; ++i) {
      v[i] += v[i-1];
    }
    cout << *max_element(begin(v), end(v)) << endl;
  }
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int n;
	
	while(cin >> n,n){
		
		vector<int> imos(25*60*60);
		REP(i,n){
			int h,m,s,tmp;
			scanf("%d:%d:%d",&h,&m,&s);
			tmp = h*(3600) + m*60 + s;
			imos[tmp]++;
			scanf("%d:%d:%d",&h,&m,&s);
			tmp = h*(3600) + m*60 + s;
			imos[tmp]--;
		}
		
		REP(i,imos.size()-1){
			imos[i+1] += imos[i];
		}
		int ans = 0;
		REP(i,imos.size()){
			ans = max(ans,imos[i]);
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

typedef struct
{
  int start;
  string time;
} Train;

class LessTime
{
public:
  bool operator() (const Train& lhs, const Train& rhs)
  {
    if (lhs.time == rhs.time)
      return lhs.start < rhs.start;
    return lhs.time < rhs.time;
  }
};

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<Train> train(2*n);
    for (int i = 0; i < 2*n; ++i) {
      cin >> train[i].time;
      if (i&1)
	train[i].start = 0;
      else
	train[i].start = 1;
    }

    sort(train.begin(), train.end(), LessTime());
    int ans = 0, pool = 0;
    for (int i = 0; i < train.size(); ++i) {
      if (train[i].start == 1) {
	if (pool == 0)
	  ++ans;
	else
	  --pool;
      } else {
	++pool;
      }
    }

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

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int t[444000];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		memset(t,0,sizeof(t));
		rep(i,n){
			int h,m,s;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*60*60+m*60+s]+=1;
			scanf("%d:%d:%d",&h,&m,&s);
			t[h*3600+m*60+s]-=1;
		}
		rep(i,444000){
			t[i+1]+=t[i];
		}
		int res=0;
		rep(i,444000){
			maxch(res,t[i]);
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,m,n) for(int i=m;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int change(string time){
    int num = (int(time[0]) -48)*100000+(int(time[1]) -48)*10000 +(int(time[3]) -48)*1000+(int(time[4]) -48)*100 + (int(time[6]) -48)*10 + (int(time[7]) -48);

    return num;
}

int main(){
    
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        // cout<<"n"<<n<<endl;
        vector<pair<int,int> > a;
        int ans=0;
        REP(i,n){
            string tmp1,tmp2;
            cin >> tmp1>>tmp2;
            pair<int,int> tmp={change(tmp1),change(tmp2)};
            // ASC2 48~57は数字
            a.push_back(tmp);
        }
        sort(a.begin(),a.end());
        // REP(i,n){
        //     cout<<a[i].first<<" "<<a[i].second<<endl;
        // }
        
        vector<pair<int,int> > b;
        REP(i,n){
            bool flag = true;
            pair<int,int> tmp3= a[i];
            REP(j,b.size()){
                if(b[j].second <= tmp3.first) {
                    flag = false;
                    b[j]=tmp3;
                    break;
                }
                
            }

            if(flag){
                b.push_back(tmp3);
                ans++;
            }
        }
        
        cout<<ans<<endl;

       
    }

    
}