Teams Formation

This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai.

Today the bus has completed m trips, each time bringing n participants. The participants were then aligned in one line in the order they arrived, with people from the same bus standing in the order of their seats (i. e. if we write down the cities where the participants came from, we get the sequence a1, a2, ..., an repeated m times).

After that some teams were formed, each consisting of k participants form the same city standing next to each other in the line. Once formed, teams left the line. The teams were formed until there were no k neighboring participants from the same city.

Help the organizers determine how many participants have left in the line after that process ended. We can prove that answer doesn't depend on the order in which teams were selected.

Input

The first line contains three integers n, k and m (1 ≤ n ≤ 105, 2 ≤ k ≤ 109, 1 ≤ m ≤ 109).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number of city, person from which must take seat i in the bus.

Output

Output the number of remaining participants in the line.

Examples
Input
```4 2 5
1 2 3 1
```
Output
```12
```
Input
```1 9 10
1
```
Output
```1
```
Input
```3 2 10
1 2 1
```
Output
```0
```
Note

In the second example, the line consists of ten participants from the same city. Nine of them will form a team. At the end, only one participant will stay in the line.

1 1 3 2 1 k = 3三个相连 1 1 3 2 1 1 1 3 2 1 1 1 3 2 1消除两个的，两头的暂时不会接触

（不是一个，因为这一种数字可能多个，注意pari数组的意义）

1、总共m*每种的个数如果是k的倍数，直接全部消去，并且要十分注意，中间都消除了，那么这是首尾就有碰面了，这样又得消除一个rec2，一共就消除了m个rec2

2、另一种当然就是不能被k整除，那么我们就只能减去k的倍数的个数

1、如果首尾数字相同，说明他们总数不是k的倍数，但是我们还是要减去小于它的k的倍数

2、如果不同那么就直接减掉我们之前统计的消掉的就好了

code：

```#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
ll a[maxn];
pair<ll,ll> st[maxn];
ll top,n,m,k,l,r,rec,rec2;
ll ans;
int main(){
cin >> n >> k >> m;
for(ll i = 1; i <= n; i++)
cin >> a[i];
for(ll i = 1; i <= n; i++){
if(!top || st[top].first != a[i])
st[++top] = make_pair(a[i],1);
else
st[top].second = (st[top].second + 1) % k;
if(st[top].second == 0) top--;
}
for(ll i = 1; i <= top; i++){
rec += st[i].second;
}
l = 1,r = top;
while(l < r && st[l].first == st[r].first && (st[l].second + st[r].second) % k == 0){
rec2 += st[l].second + st[r].second;
l++;
r--;
}
if(l == r){
if(st[l].second * m % k == 0)
ans -= rec2;
ans += m * rec - rec2 * (m - 1) - (st[l].second * m / k * k);
}
else{
if(st[l].first == st[r].first)
rec2 += (st[l].second + st[r].second) / k * k;
ans = m * rec - rec2 * (m - 1);
}
cout << ans << endl;
return 0;
}
```