#C7827. Minimum Sprinklers Needed
Minimum Sprinklers Needed
Minimum Sprinklers Needed
You are given a garden represented by a grid with $n$ rows and $m$ columns. Each cell of the garden contains a positive integer indicating the exact amount of water required by the plant at that cell.
Your task is to determine the minimum number of sprinklers needed to water the garden such that every plant receives exactly the water it requires. Each sprinkler can be configured to supply water for plants with a specific water requirement. Therefore, the minimum number of sprinklers required is equal to the number of distinct water requirement values in the garden.
Note: The input is given via standard input and the output should be printed to standard output.
inputFormat
The first line contains two integers, n and m, representing the number of rows and columns in the garden respectively.
Then follow n lines, each containing m space-separated integers. Each integer represents the water requirement for a cell in that row.
Input is given through standard input.
outputFormat
Output a single integer that is the minimum number of sprinklers needed to water the garden exactly as required.
Output should be printed to the standard output.
## sample2 2
2 2
2 2
1