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 INF = 1000000404;
const long long MOD = 1000000007ll;
const long double PI = acos(-1.0);
const long double EPS = 1e-9;
template <typename t1, typename t2>
inline void upmax(t1 &a, t2 b) {
  a = max(a, (t1)b);
}
template <typename t1, typename t2>
inline void upmin(t1 &a, t2 b) {
  a = min(a, (t1)b);
}
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
template <typename T>
inline bool pal(T &x) {
  int n = (int((x.size())));
  for (int i = 0; i < n / 2; i++) {
    if (x[i] != x[n - i - 1]) return 0;
  }
  return 1;
}
template <typename T>
inline void rev(T &x) {
  int n = (int((x.size())));
  for (int i = 0; i < n / 2; i++) swap(x[i], x[n - i - 1]);
}
int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
inline long long mp(long long a, long long b) { return (a << 31) + b; }
class compare {
 public:
  bool operator()(const int a, const int b) const { return 1; }
};
int SQ = 400;
vector<int> b;
vector<int> arr;
int a[111111];
int head(deque<int> &d) {
  int n = (int((d.size())));
  int x = d.front();
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] != x) {
      break;
    } else
      res++;
  }
  return res;
}
int tail(deque<int> &d) {
  int n = (int((d.size())));
  int x = d.back();
  int res = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (d[i] != x) {
      break;
    } else
      res++;
  }
  return res;
}
int k;
struct node {
  long long len;
  vector<int> v;
};
long long merge(vector<int> &a, vector<int> &b, vector<int> &c) {
  if (b.empty() && a.empty()) return 0;
  for (auto x : b) a.push_back(x);
  int minus = 0;
  c.push_back(a[0]);
  int last = 1;
  for (int i = 1; i < (int((a.size()))); i++) {
    if (!c.empty() && a[i] == c.back()) {
      last++;
      c.push_back(a[i]);
      if (last == k) {
        minus += k;
        for (int j = 0; j < k; j++) {
          c.pop_back();
        }
        if (!c.empty())
          last = 1;
        else
          last = 0;
      }
    } else {
      last = 1;
      c.push_back(a[i]);
    }
  }
  vector<int> v;
  if ((int((c.size()))) >= 150000) {
    for (int i = 0; i < 50005; i++) v.push_back(c[i]);
    v.push_back(-1);
    for (int i = (int((c.size()))) - 1; i >= (int((c.size()))) - 50006; i--)
      v.push_back(c[i]);
    c = v;
  }
  return minus;
}
node ret;
node REK(int m) {
  if (m == 1) {
    return ret;
  }
  if (m % 2) {
    node p1 = REK(m / 2);
    node p2 = p1;
    node p3 = ret;
    node res1, res2;
    int x = merge(p1.v, p2.v, res1.v);
    res1.len = p1.len + p2.len - x;
    x = merge(res1.v, p3.v, res2.v);
    res2.len = res1.len + p3.len - x;
    return res2;
  } else {
    node p1 = REK(m / 2);
    node p2 = p1;
    node res;
    int x = merge(p1.v, p2.v, res.v);
    res.len = p1.len + p2.len - x;
    return res;
  }
}
void solve() {
  int n, m;
  cin >> n >> k >> m;
  int allthesame = true;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    arr.push_back(a[i]);
    if (a[i] != a[1]) allthesame = false;
  }
  if (allthesame) {
    cout << (1ll * n * m) % k << endl;
  }
  int last = 1;
  b.push_back(a[1]);
  for (int i = 2; i < n + 1; i++) {
    if (!b.empty() && a[i] == b.back()) {
      last++;
      b.push_back(a[i]);
      if (last == k) {
        for (int j = 0; j < k; j++) b.pop_back();
        if (b.empty())
          last = 0;
        else
          last = 1;
      }
    } else {
      last = 1;
      b.push_back(a[i]);
    }
  }
  ret.v = b;
  ret.len = (int((b.size())));
  node v = REK(m);
  cout << v.len << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  };
  getchar();
  getchar();
  return 0;
}
