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 <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int second_per_day = 86400;

int to_sec(int hour, int minute, int second) {
  return hour * 3600 + minute * 60 + second;
}

int main() {
  int depature_times;
  vector<int> times(second_per_day, 0);

  while(true) {
    cin >> depature_times;

    if(depature_times == 0) {
      break;
    }

    // clear
    for(int i = 0; i < times.size(); i++) {
      times[i] = 0;
    }

    // preprocess
    for(int i = 0; i < depature_times; i++) {
      int hour, minute, second;

      // Deaptrue
      scanf("%d:%d:%d", &hour, &minute, &second);
      times[to_sec(hour, minute, second)] += 1;

      // Arrive
      scanf("%d:%d:%d", &hour, &minute, &second);
      times[to_sec(hour, minute, second)] += -1;
    }

    // simulate
    int tmp_max = times[0];
    for(int i = 1; i < times.size(); i++) {
      times[i] += times[i - 1];
      tmp_max = max(times[i], tmp_max);

      if(tmp_max == 4) {

      }
    }

    cout << tmp_max << endl;
  }
}

C++: ///
// File:  2013.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 19 01:11:43 2017
//

#include <array>
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    array<int32_t, 24 * 60 * 60> arr{0};
    for (uint32_t _ = 0; _ < n; _++) {
      uint32_t h, m, s;
      char __;
      cin >> h >> __ >> m >> __ >> s;
      arr[60 * 60 * h + m * 60 + s]++;
      cin >> h >> __ >> m >> __ >> s;
      arr[60 * 60 * h + m * 60 + s]--;
    }

    int32_t max_val = arr[0];
    for (uint32_t i = 0; i < arr.size() - 1; i++) {
      arr[i + 1] += arr[i];
      max_val = max(max_val, arr[i + 1]);
    }
    cout << max_val << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int imoss[60*60*24+100]={0};
        for(int i=0;i<n;i++){
            int t,m,s;
            scanf("%d:%d:%d",&t,&m,&s);
            imoss[t*3600+m*60+s]++;
            scanf("%d:%d:%d",&t,&m,&s);
            imoss[t*3600+m*60+s-1]--;
        }
        int ma=0;
        for(int i=0;i<=24*60*60;i++)ma=max(ma,imoss[i]);
        printf("%d\n",ma);
    }
    return 0;
}

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

using namespace std;

int exchange(string s){
  int res=0;
  res = (s[0]-48)*36000+(s[1]-48)*3600+(s[3]-48)*600+(s[4]-48)*60+
        (s[6]-48)*60+(s[7]-48);
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(cin >> n,n){
    int time[900000]={0};
    for(int i=0;i<n;i++){
      string s1,s2;cin >>s1>>s2;
      int start=exchange(s1),end=exchange(s2);
      time[start]++;time[end]--;
    }
    for(int i=1;i<900000;i++) time[i]+=time[i-1];
    int res=-1;
    for(int i=0;i<900000;i++) res=max(res,time[i]);
    cout << res << endl;
  }
}

C++: //#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {

	while (1) {
		int n;
		int maxi = -1;
		int dp[86402] = {};
		int h, m, s;
		char c, d;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
			dp[h * 3600 + m * 60 + s]++;
			scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
			dp[h * 3600 + m * 60 + s + 1]--;
		}
		FOR(i, 1, 86401) {
			dp[i] += dp[i - 1];
		}
		FOR(i, 1, 86401) {
			if (dp[i] > maxi) {
				maxi = dp[i];
			}
		}
		cout << maxi << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main() {
	int n;
	std::map<int, int> tv;
	for (;;) {
		cin >> n;
		if (!n) break;
		for (int i = 0; i < n; ++i) {
			int h, m, s1, s2;
			scanf("%d:%d%:%d", &h, &m, &s1);
			m += h * 60;
			s1 += m * 60;
			scanf("%d:%d:%d", &h, &m, &s2);
			m += h * 60;
			s2 += m * 60;
			++tv[s1];
			--tv[s2];
		}
		int c = 0, max = 0;
		for (auto i : tv) {
			c += i.second;
			if (max < c) max = c;
		}
		std::cout << max << std::endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

int main(){
    int n;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        int par[100000];
        fill(par, par + 100000, 0);
        for(int _ = 0; _ < n; _++){
            int h, m, s;
            scanf("%d:%d:%d", &h, &m, &s);
            par[3600 * h + 60 * m + s] += 1;
            scanf("%d:%d:%d", &h, &m, &s);
            par[3600 * h + 60 * m + s] -= 1;
        }
        int acc = 0, ans = 0;
        for(int i = 0; i < 100000; i++){
            acc += par[i];
            ans = max(ans, acc);
        }
        printf("%d\n", ans);
    }
    return 0;
}