#include <bits/stdc++.h>
using namespace std;
int n, k;
long long dp[100001][20];
long long b[100001][20];
int a[100001];
long long sum(int i, int k) {
  long long s = 0;
  while (i > 0) {
    s += b[i][k];
    i -= i & -i;
  }
  return s;
}
void add(int i, long long x, int k) {
  while (i <= n) {
    b[i][k] += x;
    i += i & -i;
  }
}
int main() {
  while (cin >> n >> k) {
    for (int i = 1; i <= n; ++i) cin >> a[i];
    memset(dp, 0, sizeof(dp));
    memset(b, 0, sizeof(b));
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      dp[a[i]][1] = 1;
      add(a[i], 1, 1);
      for (int j = 2; j <= k + 1 && j <= i; ++j) {
        dp[a[i]][j] = sum(a[i] - 1, j - 1);
        add(a[i], dp[a[i]][j], j);
      }
      ans += dp[a[i]][k + 1];
    }
    cout << ans << endl;
  }
  return 0;
}

### Prompt

Please create a solution in CPP 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;
long long dp[100001][20];
long long b[100001][20];
int a[100001];
long long sum(int i, int k) {
  long long s = 0;
  while (i > 0) {
    s += b[i][k];
    i -= i & -i;
  }
  return s;
}
void add(int i, long long x, int k) {
  while (i <= n) {
    b[i][k] += x;
    i += i & -i;
  }
}
int main() {
  while (cin >> n >> k) {
    for (int i = 1; i <= n; ++i) cin >> a[i];
    memset(dp, 0, sizeof(dp));
    memset(b, 0, sizeof(b));
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      dp[a[i]][1] = 1;
      add(a[i], 1, 1);
      for (int j = 2; j <= k + 1 && j <= i; ++j) {
        dp[a[i]][j] = sum(a[i] - 1, j - 1);
        add(a[i], dp[a[i]][j], j);
      }
      ans += dp[a[i]][k + 1];
    }
    cout << ans << endl;
  }
  return 0;
}

```