You can add them into a list, then remove duplicates and compare the size of the actual list minus the unique elements
List elements = Arrays.asList(a,b,c);
List distinct = elements.stream().distinct().toList();
return elements.size() == distinct.size() ? 0 : elements.size() - distinct.size() + 1;
distinct list contains one entry of the duplicate so we have to increment with 1 because we already decreased it.
Or use a HashSet that holds only unique elements
List elements = Arrays.asList(a,b,c);
HashSet<ArrayList> set = new HashSet<>();
set.addAll(elements);
return elements.size() == set.size() ? 0 : elements.size() - set.size() + 1;