← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strings"
)

var wordRe = regexp.MustCompile(`[a-z]+`)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan() // skip document identifier
	nameLine := ""
	if scanner.Scan() {
		nameLine = scanner.Text()
	}
	var sb strings.Builder
	sb.WriteString(nameLine)
	sb.WriteString(" ")
	for scanner.Scan() {
		sb.WriteString(scanner.Text())
		sb.WriteString(" ")
	}
	content := strings.ToLower(sb.String())
	words := wordRe.FindAllString(content, -1)
	wordCount := make(map[string]int)
	for _, w := range words {
		wordCount[w]++
	}

	class1 := []string{
		"government", "president", "election", "political", "law",
		"court", "justice", "vote", "democracy", "congress",
		"senate", "parliament", "policy", "minister", "campaign",
		"candidate", "federal", "rights", "freedom", "war",
		"peace", "treaty", "diplomatic", "republic", "democrat",
		"republican",
	}
	class2 := []string{
		"sport", "game", "team", "player", "league", "match",
		"goal", "score", "win", "championship", "tournament",
		"coach", "football", "basketball", "soccer", "tennis",
		"baseball", "hockey", "race", "athlete", "olympic",
		"medal", "defeat", "victory", "cup",
	}
	class3 := []string{
		"trade", "market", "export", "import", "economic",
		"economy", "stock", "price", "business", "commerce",
		"tariff", "investment", "revenue", "profit", "goods",
		"currency", "exchange", "trading", "supply", "demand",
		"bank", "finance", "fiscal", "budget", "tax",
	}

	c1 := sumCounts(wordCount, class1)
	c2 := sumCounts(wordCount, class2)
	c3 := sumCounts(wordCount, class3)

	if c1 > c2 && c1 > c3 {
		fmt.Println(1)
	} else if c2 > c1 && c2 > c3 {
		fmt.Println(2)
	} else if c3 > c1 && c3 > c2 {
		fmt.Println(3)
	} else {
		if c3 >= c2 && c3 >= c1 {
			fmt.Println(3)
		} else if c2 >= c1 {
			fmt.Println(2)
		} else {
			fmt.Println(1)
		}
	}
}

func sumCounts(wc map[string]int, words []string) int {
	sum := 0
	for _, w := range words {
		sum += wc[w]
	}
	return sum
}
```