class Solution {
public:
int numRabbits(vector<int>& answers) {
unordered_map<int, int> cnt;
for (int i: answers) {
++cnt[i];
}
int res = 0;
for (auto [k, v] : cnt) {
res += (v + k) / (k + 1) * (k + 1);
}
return res;
}
};