#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 7;
const int minn = 10 + 7;
struct segment_tree {
  vector<long long> tree;
  void init(int n) { tree.resize(4 * n + minn); }
  void add(int x, int lx, int rx, int i, long long v) {
    if (lx == rx) {
      tree[x] += v;
      return;
    }
    if (i <= (lx + rx) / 2) {
      add(2 * x, lx, (lx + rx) / 2, i, v);
    } else {
      add(2 * x + 1, (lx + rx) / 2 + 1, rx, i, v);
    }
    tree[x] = tree[2 * x] + tree[2 * x + 1];
  }
  long long getSum(int x, int lx, int rx, int l, int r) {
    if (l > r) return 0;
    if (r < lx || l > rx) return 0;
    if (lx >= l && rx <= r) return tree[x];
    return getSum(2 * x, lx, (lx + rx) / 2, l, r) +
           getSum(2 * x + 1, (lx + rx) / 2 + 1, rx, l, r);
  }
};
segment_tree trees[minn];
long long dp[maxn][minn];
int a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  k++;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= k; i++) trees[i].init(n + 1);
  for (int i = 1; i <= n; i++) {
    dp[i][1] = 1;
    for (int j = 1; j <= k; j++)
      if (j > 1) dp[i][j] = trees[j - 1].getSum(1, 1, n, 1, a[i] - 1);
    for (int j = 1; j <= k; j++) trees[j].add(1, 1, n, a[i], dp[i][j]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += dp[i][k];
  cout << ans;
}

### 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;
const int maxn = 100000 + 7;
const int minn = 10 + 7;
struct segment_tree {
  vector<long long> tree;
  void init(int n) { tree.resize(4 * n + minn); }
  void add(int x, int lx, int rx, int i, long long v) {
    if (lx == rx) {
      tree[x] += v;
      return;
    }
    if (i <= (lx + rx) / 2) {
      add(2 * x, lx, (lx + rx) / 2, i, v);
    } else {
      add(2 * x + 1, (lx + rx) / 2 + 1, rx, i, v);
    }
    tree[x] = tree[2 * x] + tree[2 * x + 1];
  }
  long long getSum(int x, int lx, int rx, int l, int r) {
    if (l > r) return 0;
    if (r < lx || l > rx) return 0;
    if (lx >= l && rx <= r) return tree[x];
    return getSum(2 * x, lx, (lx + rx) / 2, l, r) +
           getSum(2 * x + 1, (lx + rx) / 2 + 1, rx, l, r);
  }
};
segment_tree trees[minn];
long long dp[maxn][minn];
int a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  k++;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= k; i++) trees[i].init(n + 1);
  for (int i = 1; i <= n; i++) {
    dp[i][1] = 1;
    for (int j = 1; j <= k; j++)
      if (j > 1) dp[i][j] = trees[j - 1].getSum(1, 1, n, 1, a[i] - 1);
    for (int j = 1; j <= k; j++) trees[j].add(1, 1, n, a[i], dp[i][j]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += dp[i][k];
  cout << ans;
}

```