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

import java.io.*;
import java.util.*;

public class G {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);
    List<Pair> s;
    int[] a;
    long n, k, m, d = 0;
    boolean ansIsZero = false;

    void close() {
        out.close();
    }

    void init() {
        a = new int[((int) n)];
        s = new ArrayList<>();
    }

    void print() {
        out.print(ansIsZero ? 0 : (long) n * m - d);
    }

    void read() {
        n = in.nextLong();
        k = in.nextLong();
        m = in.nextLong();
        init();
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
    }

    void solve() {
        for (int i = 0; i < n; i++) {
            if (s.size() == 0 || s.get(s.size() - 1).first != a[i]) {
                s.add(new Pair(a[i], 1));
            } else {
                s.set(s.size() - 1, new Pair(
                        s.get(s.size() - 1).first,
                        s.get(s.size() - 1).second + 1)
                );
            }
            if (s.get(s.size() - 1).second == k) {
                d += k * m;
                s.remove(s.size() - 1);
            }
        }
        if (s.size() > 0) {
            int l = 0, r = s.size() - 1;
            while (l < r && s.get(l).first == s.get(r).second
                    && s.get(l).second + s.get(r).second >= k) {
                d += k * (m - 1);
                l++;
                r--;
            }
            if (l == r) {
                long temp = m * s.get(l).second;
                d += temp - temp % k;
                if (temp % k == 0) {
                    ansIsZero = true;
                }
            }
            else if (s.get(l).first == s.get(r).first && s.get(l).second + s.get(r).second >= k) {
                d += k * (m - 1);
            }
        }
    }

    void run() {
        read();
        solve();
        print();
        close();
    }

    public static void main(String[] args) {
        new G().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        char[][] nextCharArray(int n, int m) {
            char[][] g = new char[n][m];
            for (int i = 0; i < n; i++)
                g[i] = next().toCharArray();
            return g;
        }

        double[] nextDoubleArray(int n) {
            double[] a = new double[n];
            for (int i = 0; i < n; i++)
                a[i] = nextDouble();
            return a;
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static class Pair implements Comparable<Pair> {
        int first;
        long second;

        Pair(int first, long second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair pair) {
            if (this.first != pair.first)
                return this.first - pair.first;
            else
                return (int) (this.second - pair.second);
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Pair))
                return false;
            Pair p = (Pair) o;
            return Objects.equals(p.first, first) && Objects.equals(p.second, second);
        }

        @Override
        public int hashCode() {
            return this.first ^ (int) this.second;
        }

        @Override
        public String toString() {
            return "" + '(' + this.first + ',' + this.second + ')';
        }
    }
}