#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct node {
  int x, y;
} mp[MAXN];
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  int top = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (top == 0 || mp[top].x != t) {
      mp[++top].x = t;
      mp[top].y = 1;
    } else
      mp[top].y = (mp[top].y + 1) % k;
    if (mp[top].y == 0) top--;
  }
  long long rec = 0, rec2 = 0;
  for (int i = 1; i <= top; i++) rec += mp[i].y;
  int l = 1, r = top;
  while (l < r && mp[l].x == mp[r].x && (mp[l].y + mp[r].y) % k == 0) {
    rec2 += mp[l].y + mp[r].y;
    l++;
    r--;
  }
  long long ans = 0;
  if (l == r) {
    if (mp[l].y * m % k == 0) {
      cout << 0 << endl;
      return 0;
    }
    ans = rec * m - rec2 * (m - 1) - mp[l].y * m / k * k;
  } else {
    if (mp[l].x == mp[r].x) rec2 += (mp[l].y + mp[r].y) / k * k;
    ans = rec * m - rec2 * (m - 1);
  }
  cout << ans << endl;
  return 0;
}
