Is your horseshoe on the other hoof?

Practice this coding question on Coding Gurukul.

Problem statement

A craft workshop prepares a four-piece horseshoe display. The design requires all four pieces to have different colour codes, but the current collection may contain repeated colours. The shop has replacement pieces in any new colour, so the only question is how many existing pieces must be replaced. Your program supplies the minimum purchase count to the workshop organiser. Your task Read the four current colour codes. Determine the minimum number of new pieces needed so the final collection contains four distinct colours. One piece of each currently present colour can be kept; every additional occurrence of that colour must be replaced by a different colour. Important details Colour codes are identifiers, not brightness values, so their numeric distance is irrelevant. The four pieces need not be sorted. If all four colours already differ, no purchase is necessary. Worked example For colour codes 5, 5, 8 and 9, the workshop can keep one 5, the 8 and the 9. Only the second 5 needs replacement, so print 1.

Input format

One line containing four integer colour codes.

Output format

Print the minimum number of new pieces.

Constraints

1 <= each colour code <= 1000000000.

Sample input

5 5 8 9

Sample output

1

Sign in to run or submit a solution in C++, Java or Python.