P2943 [USACO09MAR] Cleaning Up G

Description

In the good old days, Farmer John served a boring cuisine comprising but a single type of cow food to his N (1

Input Format

\* Line 1: Two space-separated integers: N and M \* Lines 2..N+1: Line i+1 contains a single integer: P\_i

Output Format

\* Line 1: A single integer: the minimum amount of time FJ must spend cleaning the barn.

Explanation/Hint

There are four types of food and thirteen cows in line. The first cow prefers type 1, the second type 2, the third type 1, etc. The first four groups contain one cow each. The fifth group contains two cows who prefer food #2 (requiring one unit of time). The sixth group contains cows preferring foods 3, 4, 3, 4, 3 (and requires four units of time to clean). The last two groups contain one cow each. The total time is 11.