```
public class Solution {
public int distributeCandies(int[] candies) {
return Math.min(candies.length/2, (int)IntStream.of(candies).distinct().count());
}
}
```

The `distinct()`

method returns a stream with distinct elements, and the `count()`

returns a `long`

value representing the count of the elements.