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 <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

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

        vector<int> acum(24 * 3600 + 5);
        vector<int> simul(24 * 3600 + 5);
        REP(i, N) {
            string s, t;
            cin >> s >> t;
            vector<string> s_split = split(s, ':');
            vector<string> t_split = split(t, ':');
            int s_int = stoi(s_split[0]) * 60 * 60 + stoi(s_split[1]) * 60 + stoi(s_split[2]);
            int t_int = stoi(t_split[0]) * 60 * 60 + stoi(t_split[1]) * 60 + stoi(t_split[2]);
            // if(s_int == t_int) cerr << s << " " << t << endl;
            acum[s_int]++;
            acum[t_int]--;
            // if(s_int == t_int) simul[s_int]++;
        }
        FOR(i, 1, 24 * 3600)
            acum[i] += acum[i-1];

        int ans = 0;
        FOR(i, 0, 24 * 3600)
            ans = max(ans, acum[i]);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

typedef vector<int> vi;
typedef vector< vi > vvi;

typedef long L;
typedef long long LL;

const int SECOND_OF_DAY = 24 * 60 * 60;

LL toSecond(int h, int m, int s) {
	return (LL)h * 60 * 60 + (LL)m * 60 + (LL)s;
}

int main(void) {
	int N;
	while (cin >> N, N) {
		vi time(SECOND_OF_DAY, 0);

		for (int i = 0; i < N; i++) {
			int h, m, s;
			char buf;
			cin >> h >> buf >> m >> buf >> s;
			LL start = toSecond(h, m, s);
			cin >> h >> buf >> m >> buf >> s;
			LL end = toSecond(h, m, s);

			for (LL i = start; i < end; i++) {
				time[i]++;
			}
		}

		cout << *(max_element(time.begin(), time.end())) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <map>

#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

//??\???

int conv(string s) {
  string hh="", mm="", ss="";
  hh += s[0]; hh += s[1];
  mm += s[3]; mm += s[4];
  ss += s[6]; ss += s[7];

  return stoi(hh) * 60 * 60 + stoi(mm) * 60 + stoi(ss);
}

int main() {
  ios::sync_with_stdio(false);

  int N;
  while(cin >> N) {

    if(N == 0) break;

    map<int,int> imos;
    for(int i = 0; i < N; i++) {
      string s1, s2;
      cin >> s1 >> s2;
      imos[ conv(s1) ] += 1;
      imos[ conv(s2) ] -= 1;
    }

    int mx = 0, num = 0;
    for(map<int,int>::iterator it = imos.begin(); it != imos.end(); it++) {
      num += (it -> second);
      mx = max(mx, num);
    }
    cout << mx << endl;
  }

  return 0;
}

C++: #pragma GCC optimize("O3")
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
  int d;
  cin>>d;
  if(d==0)return 0;
  multiset<P> dat;
  for(int i=0;i<d;i++){
    string s,t;
    cin>>s>>t;
    ll a=0,b=0;
    ll n=ll(s[0]-'0'),m=ll(t[0]-'0');
    n*=10;m*=10;
    n+=ll(s[1]-'0'),m+=ll(t[1]-'0');
    a+=3600*n,b+=3600*m;
    n=0,m=0;
    n+=ll(s[3]-'0'),m+=ll(t[3]-'0');
    n*=10;m*=10;
    n+=ll(s[4]-'0'),m+=ll(t[4]-'0');
    a+=60*n,b+=60*m;
    n=0,m=0;
    n+=ll(s[6]-'0'),m+=ll(t[6]-'0');
    n*=10;m*=10;
    n+=ll(s[7]-'0'),m+=ll(t[7]-'0');
    a+=n;b+=m;
    dat.insert({a,b});
  }
  int ans=0;
  while(dat.size()){
    ll bfo=-1;
    ans++;
    for(auto ite=dat.begin();ite!=dat.end();){
      if(bfo<=(*ite).fi){
        bfo=(*ite).se;
        ite=dat.erase(ite);
      }else ite++;
    }
  }
  cout<<ans<<"\n";
}
}