Ginger the horse is going for brunch with his friends. He has been collecting the fashion trends magazine for a while, and he knows that it is trendy to wear all horseshoes of a different colors. Ginger has got four horseshoes left from the previous year, but maybe some of the horseshoes have the same color. So he needs to go to the shop and buy a few more horseshoes.
Surprisingly, the shop sells horseshoes of all colors under the sun and Ginger has enough money to buy any four of them. However, to save money, he would like to spend as little money as possible. Find the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a brunch.
Input Format
Input consists four space-separated integers k1, k2, k3, k4 the colors of horseshoes Ginger has and consider all possible colors indexed with integers.
Constraints
(1 ≤ k1, k2, k3, k4 ≤ 10^9)
Output Format
Print single positive integer that is the minimum number shoes that he needs to shop for his brunch.
Sample Input 0
1 7 3 3
Sample Output 0
1
Explanation 0
In the input, the colours (indexed with integers) 1,7,3,3 represent the different colours of horseshoes that Ginger has. We can see that he has two of the same colour which would make it impossible for him to wear four different horseshoes at the brunch. That is why, Ginger needs to buy 1 horseshoe to make four different horseshoes.
Sample Input 1
255635360 732742923 798648949 883146723
Sample Output 1
0
What I have tried:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] arr = new long[4];
for(int i = 0;i<n;i++){
arr[i] = sc.nextInt();
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(arr[i] == arr[j]){
System.out.println("1");
}
if(arr[i] != arr[j]){
System.out.println("0");
}
}
}
}
}