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;
using li = long long;
using ld = long double;
const int MAX = 1e5 + 100;
int k;
struct State {
  vector<pair<int, int>> cnt;
  li add = 0;
  void push(pair<int, int> x) {
    if (cnt.empty() || cnt.back().first != x.first) {
      cnt.push_back(x);
    } else {
      cnt.back().second += x.second;
      while (!cnt.empty() && cnt.back().second >= k) {
        cnt.back().second %= k;
        if (cnt.back().second == 0) cnt.pop_back();
      }
    }
  }
  void optimize() {
    if (cnt.size() > 2 * MAX) {
      auto from = cnt.begin() + MAX;
      auto to = cnt.end() - MAX;
      for (auto it = from; it != to; it++) add += it->second;
      cnt.erase(from, to);
    }
  }
  void push(vector<int>& v) {
    for (int x : v) push(make_pair(x, 1));
    optimize();
  }
  void push(State& v) {
    cnt.reserve(cnt.size() + v.cnt.size());
    add += v.add;
    for (auto x : v.cnt) push(x);
    optimize();
  }
  li get_count() {
    li ans = 0;
    for (auto it : cnt) {
      ans += it.second;
    }
    ans += add;
    return ans;
  }
};
State rep(State s, int k) {
  if (k == 1) return s;
  State y = s;
  y.push(s);
  y = rep(y, k / 2);
  if (k % 2 == 1) y.push(s);
  return y;
}
void solve(bool read) {
  int n, m;
  if (read)
    cin >> n >> k >> m;
  else {
    n = 1e4;
    k = 1117;
    m = 1e9;
  }
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    if (read)
      cin >> a[i];
    else
      a[i] = 1;
  State s;
  s.push(a);
  s = rep(s, m);
  cout << s.get_count() << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int nt = 1;
  for (int i = 0; i < nt; i++) solve(true);
  return 0;
}
