#K94452. Remaining Sellers

    ID: 38644 Type: Default 1000ms 256MiB

Remaining Sellers

Remaining Sellers

You are given an initial number of sellers S and a list of M merger events. Each merger event is described by a pair of integers u and v, which indicates that seller u merges into seller v. After a merger, seller u ceases to exist, whereas seller v continues operating.

Your task is to determine the number of sellers that remain active after processing all merger events. Note that if a seller loses multiple times (i.e. appears as the first element more than once), they are only counted once as merged out.

The mathematical formulation is as follows:

$$\text{Remaining Sellers} = S - \left|\{ u : (u,v) \text{ is a merger event}\}\right|.$$

inputFormat

The input is read from standard input. The first line contains two integers S and M, where S is the initial number of sellers and M is the number of merger events. This is followed by M lines, each containing two integers u and v representing a merger event in which seller u merges into seller v.

outputFormat

Output a single integer to standard output — the number of remaining sellers after processing all the mergers.## sample

5 0
5

</p>