10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, k, m;
vector<pair<int, int>> normalize(const vector<pair<int, int>>& v) {
  vector<pair<int, int>> res;
  int curr = 0;
  while (curr < v.size()) {
    while (!res.empty() && curr < v.size() &&
           v[curr].first == res.back().first) {
      res.back().second += v[curr].second;
      res.back().second %= k;
      if (res.back().second == 0) {
        res.pop_back();
      }
      ++curr;
    }
    if (curr == v.size()) break;
    res.push_back(v[curr]);
    ++curr;
  }
  return res;
}
long long getSz(const vector<pair<int, int>>& v) {
  long long res = 0;
  for (auto& x : v) {
    res += x.second;
  }
  return res;
}
struct Comp {
  vector<pair<int, int>> all;
  void norm() {
    all = normalize(all);
    if (all.size() <= 2 * N) return;
    long long sz = getSz(all);
    vector<pair<int, int>> res;
    for (int i = 0; i < N; ++i) {
      res.push_back(all[i]);
      sz -= all[i].second;
    }
    res.emplace_back(-1, 0);
    int mid_ind = res.size() - 1;
    for (int i = (int)all.size() - N; i < all.size(); ++i) {
      res.push_back(all[i]);
      sz -= all[i].second;
    }
    res[mid_ind].second = sz;
    all = res;
  }
  void print() {
    cout << "All: ";
    for (auto& x : all) {
      cout << "{" << x.first << "," << x.second << "}"
           << " ";
    }
    cout << endl;
    cout << "Sz: " << getSz(all) << endl;
  }
};
vector<pair<int, int>> base_vp;
vector<pair<int, int>> concat(const vector<pair<int, int>>& a,
                              const vector<pair<int, int>>& b) {
  vector<pair<int, int>> res;
  res.insert(res.end(), a.begin(), a.end());
  res.insert(res.end(), b.begin(), b.end());
  return res;
}
Comp calc(int m) {
  if (m == 0) {
    return Comp();
  }
  if (m == 1) {
    Comp res;
    res.all = base_vp;
    return res;
  }
  Comp tmp = calc(m / 2);
  Comp res;
  res.all = concat(tmp.all, tmp.all);
  if (m & 1) {
    res.all = concat(res.all, base_vp);
  }
  res.norm();
  return res;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    base_vp.push_back({x, 1});
  }
  base_vp = normalize(base_vp);
  Comp res = calc(m);
  cout << getSz(res.all) << endl;
}
