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 int N = 1e5 + 10;
pair<int, int> st[N];
int main() {
  int x, n, k, m;
  while (cin >> n >> k >> m) {
    int top = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      if (top && x == st[top].first)
        st[top].second++;
      else
        st[++top].first = x, st[top].second = 1;
      if (st[top].second == k) top--;
    }
    if (top == 1) {
      cout << 1LL * st[1].second * m % k << endl;
      continue;
    }
    int res = 0;
    for (int i = 1; i <= top; i++) res += st[i].second;
    if (m == 1) {
      cout << res << endl;
      continue;
    }
    int p = 0;
    for (int i = 1; i <= top - i + 1; i++) {
      if (st[i].first != st[top - i + 1].first ||
          st[i].second + st[top - i + 1].second != k)
        break;
      p = i;
    }
    if (p >= top - top / 2) {
      if (m % 2 == 0)
        cout << 0 << endl;
      else
        cout << res << endl;
    } else {
      if (top % 2 == 0 || p != top / 2) {
        long long dec = p * k;
        if (st[p + 1].first == st[top - p].first)
          dec += st[p + 1].second + st[top - p].second -
                 (st[p + 1].second + st[top - p].second) % k;
        cout << 1LL * m * res - (m - 1) * dec << endl;
      } else if (p == top / 2) {
        if (1LL * m * st[p + 1].second % k == 0)
          cout << 0 << endl;
        else {
          res = 0;
          for (int i = 1; i <= p; i++)
            res += st[i].second + st[top - i + 1].second;
          cout << res + 1LL * m * st[p + 1].second % k << endl;
        }
      }
    }
  }
  return 0;
}
