#include [[nodiscard]] static inline constexpr std::vector prepare(const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector& A) noexcept { std::vector count_of(N, 0); for (const auto& a : A) ++count_of[a - 1]; return count_of; } [[nodiscard]] static inline constexpr bool check([[maybe_unused]] const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const uint_fast32_t T, const std::vector& count_of, const uint_fast32_t c) noexcept { uint_fast32_t count = 0; for (const auto& num : count_of) if (num > c) count += num - c; for (const auto& num : count_of) if (num <= c) { if (count <= (c - num) / T) return true; else count -= (c - num) / T; } return false; } [[nodiscard]] static inline constexpr uint_fast32_t solve(const uint_fast32_t N, const uint_fast32_t M, const uint_fast32_t T, const std::vector& count_of) noexcept { uint_fast32_t l = 0, r = M; while (l + 1 < r) { const auto c = (l + r) / 2; if (check(N, M, T, count_of, c)) r = c; else l = c; } return r; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M, T; std::cin >> N >> M >> T; std::vector A(M); for (auto& a : A) std::cin >> a; std::cout << solve(N, M, T, prepare(N, M, A)) << '\n'; return 0; }