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;
stack<int> s;
vector<int> a;
const int maxn = 100000 + 10;
struct node {
  int cnt;
  int val;
};
vector<node> ans;
int main() {
  long long n, m, k;
  cin >> n >> k >> m;
  int tmp;
  bool flag = true;
  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;
  }
  long long res = n * m;
  bool f = false;
  for (int j = 1; j <= m; j++) {
    if (j == 3 and !f) {
      res = 0;
      break;
    }
    for (int i = 0; i < n; i++) {
      if (ans.empty() or (ans.back()).val != a[i]) {
        ans.push_back(node{1, a[i]});
      } else {
        (ans.back()).cnt++;
      }
      if ((ans.back()).cnt == k) ans.erase(--ans.end()), res -= k, f = true;
      ;
    }
  }
  cout << res << endl;
  return 0;
}
