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;
long long max1(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min1(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int main() {
  long long n, kk, m;
  scanf("%lld", &(n));
  scanf("%lld", &(kk));
  scanf("%lld", &(m));
  long long A11[n];
  vector<long long> A;
  bool same_flag = 1;
  for (int i = 0; i < n; ++i) {
    cin >> A11[i];
    if (A11[i] != A11[0]) same_flag = 0;
  }
  for (int i = 0; i < n; ++i) {
    long long temp = A11[i];
    long long count = 0;
    while (i < n && A11[i] == temp) {
      i++;
      count++;
    }
    i--;
    count = count % kk;
    while (count--) {
      A.push_back(temp);
    }
  }
  n = A.size();
  if (kk >= n || same_flag) {
    if (!same_flag)
      cout << n * m << endl;
    else {
      cout << ((n * m) % kk) << endl;
    }
  } else {
    vector<long long> arr;
    long long start = 0;
    long long end = n - 1;
    long long last = 0;
    while (start <= end) {
      long long temp = A[start];
      long long count = 0;
      while (A[start] == temp && start <= end) {
        start++;
        count++;
      }
      while (A[end] == temp && end > start) {
        end--;
        count++;
      }
      arr.push_back(count);
      last = start - count;
    }
    long long res = n * m;
    for (int i = 0; i < arr.size(); ++i) {
      bool flag1 = 0;
      if (arr[i] >= kk) {
        res -= (m - 1) * ((arr[i] / kk) * kk);
        if (arr[i] % kk != 0) flag1 = 1;
      }
      if (arr[i] < kk || flag1) {
        if (i == arr.size() - 1) {
          res -= (((m)*arr[i]) / kk) * kk;
          if (((m)*arr[i]) % kk == 0) {
            for (int j = i - 1; j >= 0; --j) {
              if (arr[j] >= kk) {
                res -= ((arr[j] / kk) * kk);
                if (arr[j] % kk != 0) j++;
              }
            }
          }
        }
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
}
