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;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n, k, m;
  cin >> n >> k >> m;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (k > n * m) {
    cout << n;
  } else {
    int del = 0;
    int newArr[n];
    int l = 0;
    int streak = 0;
    stack<pair<int, int> > stk;
    int current = arr[0];
    int change = 0;
    l = 0;
    while (l != n) {
      if (stk.size() > 0 && stk.top().first == arr[l]) {
        stk.top().second++;
      } else {
        stk.push({arr[l], 1});
      }
      if (stk.top().second == k) {
        stk.pop();
        del += k;
      }
      l++;
    }
    int newn = 0;
    while (!stk.empty()) {
      int num = stk.top().first;
      int freq = stk.top().second;
      stk.pop();
      for (int j = 0; j < freq; j++) {
        arr[newn++] = num;
      }
    }
    reverse(arr, arr + newn);
    int cL = 0, cR = newn - 1;
    long long int waiting = 0;
    bool filled = false;
    while (cL < newn && cR >= 0 && cR >= cL) {
      int toSeek = arr[cL];
      do {
        cL++;
        waiting++;
      } while (cL <= cR && (cL) < newn && waiting < k && arr[cL] == toSeek);
      while (cL <= cR && (cR) >= 0 && waiting < k && arr[cR] == toSeek) {
        cR--;
        waiting++;
      }
      if (waiting == k) {
        del += k;
        waiting = 0;
      } else if (cL > cR) {
        filled = true;
        break;
      } else {
        break;
      }
    }
    long long int remain;
    if (!filled) {
      remain = n * m - m * del + ((waiting != 0) ? k : 0);
    } else {
      remain = (waiting * m) % k;
    }
    cout << remain;
  }
  return 0;
}
