#include <bits/stdc++.h>
using namespace std;
int n, k, ind;
const int MAXN = 100000, MAXK = 10;
long long A[MAXN + 10];
long long bit[MAXK + 3][MAXN + 1];
long long dp[MAXK + 3][MAXN + 1];
map<long long, int> id;
long long query(int B, int pos) {
  long long sum = 0LL;
  while (pos > 0) {
    sum += bit[B][pos];
    pos -= pos & -pos;
  }
  return sum;
}
void upd(int B, int pos, long long val) {
  while (pos < ind) {
    bit[B][pos] += val;
    pos += pos & -pos;
  }
}
long long B[MAXN + 10];
int main() {
  scanf("%d %d", &n, &k);
  k++;
  ind = 1;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &A[i]);
    B[i] = A[i];
  }
  sort(B, B + n);
  for (int i = 0; i < n; i++) {
    if (id.count(B[i]) == 0) id[B[i]] = ind++;
  }
  for (int i = 0; i < n; i++) A[i] = id[A[i]];
  for (int i = 0; i < n; i++) {
    dp[1][i] = 1LL;
    upd(1, A[i], 1LL);
    for (int j = 2; j <= k; j++) {
      dp[j][i] += query(j - 1, A[i] - 1);
      upd(j, A[i], dp[j][i]);
    }
  }
  long long answer = 0LL;
  for (int i = 0; i < n; i++) answer += dp[k][i];
  printf("%I64d\n", answer);
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.

Input

First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number of elements in increasing subsequences.

Next n lines contains one integer ai (1 ≤ ai ≤ n) each — elements of sequence. All values ai are different.

Output

Print one integer — the answer to the problem.

Examples

Input

5 2
1
2
3
5
4


Output

7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k, ind;
const int MAXN = 100000, MAXK = 10;
long long A[MAXN + 10];
long long bit[MAXK + 3][MAXN + 1];
long long dp[MAXK + 3][MAXN + 1];
map<long long, int> id;
long long query(int B, int pos) {
  long long sum = 0LL;
  while (pos > 0) {
    sum += bit[B][pos];
    pos -= pos & -pos;
  }
  return sum;
}
void upd(int B, int pos, long long val) {
  while (pos < ind) {
    bit[B][pos] += val;
    pos += pos & -pos;
  }
}
long long B[MAXN + 10];
int main() {
  scanf("%d %d", &n, &k);
  k++;
  ind = 1;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &A[i]);
    B[i] = A[i];
  }
  sort(B, B + n);
  for (int i = 0; i < n; i++) {
    if (id.count(B[i]) == 0) id[B[i]] = ind++;
  }
  for (int i = 0; i < n; i++) A[i] = id[A[i]];
  for (int i = 0; i < n; i++) {
    dp[1][i] = 1LL;
    upd(1, A[i], 1LL);
    for (int j = 2; j <= k; j++) {
      dp[j][i] += query(j - 1, A[i] - 1);
      upd(j, A[i], dp[j][i]);
    }
  }
  long long answer = 0LL;
  for (int i = 0; i < n; i++) answer += dp[k][i];
  printf("%I64d\n", answer);
  return 0;
}

```