#include using namespace std; #include using namespace atcoder; using mint = atcoder::modint998244353; // using mint = double; //PBDS-tree #if __has_include() #include #include #include using namespace __gnu_pbds; template using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>; //tree.find_by_order(k) = tree[k] (0-indexed) //tree.order_of_key(k) = tree.lower_bound(k) - tree.begin() //Note: Can only be used for non-multiple sets. #endif #define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++) #define ll long long #define ld long double #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define siz(x) (int)(x).size() template bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1e9; const ll INF = 4e18; template using pq = priority_queue, less>; template using spq = priority_queue, greater>; vector di = {0, 0, 1, -1}; vector dj = {1, -1, 0, 0}; struct Edge { int to, cost; }; void solve() { int N, M, T; cin >> M >> N >> T; vector C(M, 0); rep(i, 0, N) { int a; cin >> a; C[a-1]++; } auto isok = [&](int x) -> bool { int cnt = 0; rep(i, 0, M) { if (C[i] > x) cnt += C[i] - x; } int v = 0; rep(i, 0, M) { if (C[i] <= x) v += (x - C[i]) / T; } if (cnt <= v) return true; return false; }; int ok = N, ng = 0; while(ok-ng>1) { int mid = (ok + ng) / 2; if (isok(mid)) ok = mid; else ng = mid; } cout << ok << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int T = 1; // cin >> T; while(T--) { solve(); } }