#include <bits/stdc++.h>
using namespace std;
const int max_n = 511111, max_k = 12;
int n, k, a[max_n];
long long t[max_n], dp[max_k][max_n];
void update(int i, long long x) {
  for (; i < n; i = (i | (i + 1))) {
    t[i] += x;
  }
}
long long get_sum(int r) {
  long long res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    res += t[r];
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  ++k;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    dp[1][i] = 1;
  }
  for (int i = 2; i <= k; ++i) {
    memset(t, 0, sizeof(t));
    for (int j = 0; j < n; ++j) {
      dp[i][j] = get_sum(a[j] - 1);
      update(a[j], dp[i - 1][j]);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += dp[k][i];
  }
  cout << ans << endl;
  return 0;
}

### Prompt

Generate 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;
const int max_n = 511111, max_k = 12;
int n, k, a[max_n];
long long t[max_n], dp[max_k][max_n];
void update(int i, long long x) {
  for (; i < n; i = (i | (i + 1))) {
    t[i] += x;
  }
}
long long get_sum(int r) {
  long long res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    res += t[r];
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  ++k;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    dp[1][i] = 1;
  }
  for (int i = 2; i <= k; ++i) {
    memset(t, 0, sizeof(t));
    for (int j = 0; j < n; ++j) {
      dp[i][j] = get_sum(a[j] - 1);
      update(a[j], dp[i - 1][j]);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += dp[k][i];
  }
  cout << ans << endl;
  return 0;
}

```