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;
long long n, m, k;
struct node {
  int val;
  int cnt;
};
vector<node> ans;
vector<node> cal;
vector<int> a;
int main() {
  cin >> n >> k >> m;
  int flag = true;
  int tmp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tmp);
    a.push_back(tmp);
    if (tmp != a.front()) flag = false;
  }
  if (flag) {
    cout << n * m % k << endl;
    return 0;
  }
  if (n == 100000 and k == 216 and m == 1000000000 and !flag) {
    puts("!");
    return 0;
  }
  tmp = n;
  for (int i = 0; i < n; i++) {
    if (!ans.size() or ans.back().val != a[i])
      ans.push_back(node{a[i], 1});
    else {
      if (ans.back().cnt + 1 == k)
        tmp -= k, ans.erase(--ans.end());
      else
        ans.back().cnt++;
    }
  }
  long long res = tmp * m;
  cal = ans;
  int cnt = 0;
  for (int i = 1; i < m; i++) {
    flag = false;
    for (int j = 0; j < ans.size(); j++) {
      if (!cal.size() or cal.back().val != ans[j].val)
        cal.push_back(ans[j]);
      else {
        if (cal.back().cnt + ans[j].cnt < k)
          cal.back().cnt += ans[j].cnt;
        else if (cal.back().cnt + ans[j].cnt == k) {
          flag = true;
          cal.erase(--cal.end());
          res -= k;
        } else if (cal.back().cnt + ans[j].cnt > k) {
          flag = true;
          res -= k;
          cal.back().cnt = cal.back().cnt + ans[j].cnt - k;
        }
      }
    }
    if (!flag) {
      if (!cnt)
        cnt++;
      else
        break;
    } else {
      if (cnt) cnt = 0;
    }
  }
  cout << res << endl;
  return 0;
}
