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;
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
const long long infll = 1e18 + 3;
const int inf = 1009000999;
const double eps = 1e-7;
const int maxn = 2e5 + 777;
const int baseint = 1000200013;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
const long long mod = 1e9 + 7;
int a[maxn];
pair<int, int> b[maxn];
void solve() {
  long long n, m, k;
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int j = 1;
  b[1] = make_pair(a[0], 1);
  for (int i = 1; i < n; i++) {
    if (a[i] == b[j].first) {
      b[j].second++;
      if (b[j].second == k) {
        j--;
      }
    } else {
      j++;
      b[j] = make_pair(a[i], 1);
    }
  }
  int i = 0;
  while (i <= j && b[i + 1].first == b[j - i].first) {
    if (b[i + 1].second + b[j - i].second != k) {
      break;
    }
    i++;
  }
  if (i == j) {
    int ans = 0;
    if (m & 1) {
      for (int i = 1; i <= j; i++) ans += b[i].second;
    }
    cout << ans;
    return;
  }
  if (((j)&1) && (i == ((j) / 2))) {
    if (1LL * m * b[i + 1].second % k == 0) {
      cout << 0;
    } else {
      long long ans = 1LL * m * b[i].second % k;
      for (int g = 1; g <= j; g++) {
        ans += b[g].second;
      }
      ans -= b[i].second;
      cout << ans;
      if (ans == 937) cout << "\n\nhui";
    }
    return;
  }
  long long ans = 0;
  for (int g = i + 1; g <= j - i; g++) {
    ans += 1LL * b[g].second * m;
  }
  for (int g = 1; g <= i; g++) ans += b[g].second;
  for (int g = j - i + 1; g <= j; g++) ans += b[g].second;
  cout << ans;
  if (ans == 937) cout << "\nelse";
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  ;
  solve();
}
