A counting device, comprising: an input part for inputting a first sentence and a second sentence; a syntax analyzing part for generating a syntax tree of the first sentence and a syntax tree of the second sentence by accomplishing syntax analysis on the first sentence and the second sentence; a subtree generating part for generating one or multiple first subtrees that are subtrees composing the first sentence or portions of the first sentence, from the generated syntax tree of the first sentence, and generating one or multiple second subtrees that are subtrees composing the second sentence or portions of the second sentence, from the generated syntax tree of the second sentence; a match determination part for determining whether or not a first expression represented by a first subtree composing a subtree combination and a second expression represented by a second subtree composing the subtree combination represent matching content, for one or multiple subtree combinations that are combinations of the one or any one of the multiple first subtrees generated and the one or any one of the multiple second subtrees generated; a categorizing part for categorizing a first subtree representing a first expression and a second subtree representing a second expression into the same group for one combination of the first expression and the second expression determined to be representing matching content, or respective multiple combinations of the first expression and the second expression determined to be representing matching content; and, an output part for outputting the number of subtrees categorized into the same group, and an expression respectively represented by one subtree or multiple subtrees categorized into the group. an input part for inputting a first sentence and a second sentence; a syntax analyzing part for generating a syntax tree of the first sentence and a syntax tree of the second sentence by accomplishing syntax analysis on the first sentence and the second sentence; a subtree generating part for generating one or multiple first subtrees that are subtrees composing the first sentence or portions of the first sentence, from the generated syntax tree of the first sentence, and generating one or multiple second subtrees that are subtrees composing the second sentence or portions of the second sentence, from the generated syntax tree of the second sentence; a match determination part for determining whether or not a first expression represented by a first subtree composing a subtree combination and a second expression represented by a second subtree composing the subtree combination represent matching content, for one or multiple subtree combinations that are combinations of the one or any one of the multiple first subtrees generated and the one or any one of the multiple second subtrees generated; a categorizing part for categorizing a first subtree representing a first expression and a second subtree representing a second expression into the same group for one combination of the first expression and the second expression determined to be representing matching content, or respective multiple combinations of the first expression and the second expression determined to be representing matching content; and, an output part for outputting the number of subtrees categorized into the same group, and an expression respectively represented by one subtree or multiple subtrees categorized into the group.