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 long long INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;
long long a[100000 + 5];
bool seen[100000 + 5];
struct item {
  long long val, pos;
  long long cnt;
};
bool check_same(vector<item>& seq) {
  for (long long i = 0; i < (long long)(seq).size(); i++) {
    if (seq[i].val != seq[0].val) return false;
  }
  return true;
}
vector<item> reduce(vector<item>& seq, long long k) {
  memset(seen, false, sizeof(seen));
  ;
  stack<item> s;
  for (auto it = seq.begin(); it != seq.end(); it++) {
    if (s.empty() or it->val != s.top().val) {
      it->cnt = 1;
    } else
      it->cnt = s.top().cnt + 1;
    s.push(*it);
    if (it->cnt == k) {
      vector<item> deleted;
      bool ok = true;
      for (long long i = 0; i < k; i++) {
        if (seen[s.top().pos]) {
          ok = false;
          break;
        }
        seen[s.top().pos] = true;
        deleted.push_back(s.top());
        s.pop();
      }
      if (not ok) {
        reverse(deleted.begin(), deleted.end());
        for (auto it : deleted) s.push(it);
      }
    }
  }
  vector<item> ret;
  while (!s.empty()) {
    ret.push_back(s.top());
    s.pop();
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
void print(vector<item>& seq) {
  for (long long i = 0; i < (long long)(seq).size(); i++) {
  }
}
int32_t main() {
  long long n, k, m;
  cin >> n >> k >> m;
  long long total = m * n;
  vector<item> seq;
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    ;
    seq.push_back((item){a[i], i, 1});
  }
  if (check_same(seq)) {
    cout << total % k << endl;
    return 0;
  }
  seq = reduce(seq, k);
  print(seq);
  n = (long long)(seq).size();
  for (long long i = 0; i < n; i++) {
    seq[i].pos = i;
    seq.push_back(seq[i]);
  }
  seq = reduce(seq, k);
  print(seq);
  vector<item> left, mid, right;
  memset(seen, false, sizeof(seen));
  ;
  bool start_mid = false;
  for (long long i = 0; i < (long long)(seq).size(); i++) {
    if (seen[seq[i].pos]) {
      mid.push_back(seq[i]);
      start_mid = true;
    } else if (start_mid)
      right.push_back(seq[i]);
    else
      left.push_back(seq[i]);
    seen[seq[i].pos] = true;
  }
  for (long long i = 0; i < (long long)(mid).size(); i++) left.pop_back();
  print(left);
  print(mid);
  print(right);
  if (not check_same(mid)) {
    long long ans = (long long)(left).size() + (long long)(right).size() +
                    m * (long long)(mid).size();
    cout << ans << endl;
    return 0;
  }
  long long total_mid = (long long)(mid).size() * m;
  if (total_mid % k != 0) {
    long long ans =
        (long long)(left).size() + (long long)(right).size() + (total_mid % k);
    cout << ans << endl;
  } else {
    for (auto it : right) left.push_back(it);
    vector<item> res = reduce(left, k);
    print(res);
    cout << (long long)(res).size() << endl;
  }
  return 0;
}
