#C2079. Extract and Sort Distinct Words

    ID: 45355 Type: Default 1000ms 256MiB

Extract and Sort Distinct Words

Extract and Sort Distinct Words

Given a paragraph of text, extract all unique words ignoring punctuation and case. A word is defined as a sequence of alphabetic characters, i.e. letters AZ and az. After extracting the words, sort them in alphabetical order.

The output should display the total number of distinct words on the first line, followed by each word on a new line. For example, if the input is:

Hello, world! A new world awaits; the brave and the curious.

Then the output should be:

9
a
and
awaits
brave
curious
hello
new
the
world

All comparisons are case-insensitive, meaning that words differing only in letter case should be treated as identical. Use standard input (stdin) and output (stdout) for reading input and printing the results.

inputFormat

The input consists of a paragraph of text that may span multiple lines. It may include letters, spaces, punctuation, and newline characters. The entire paragraph is given through standard input (stdin).

outputFormat

The output should start with an integer on the first line representing the total number of distinct words extracted from the input. Each subsequent line should contain one distinct word in alphabetical order.

## sample
Hello, world! A new world awaits; the brave and the curious.
9

a and awaits brave curious hello new the world

</p>