#include <bits/stdc++.h>
using namespace std;
const int N = 300500;
int a[100500];
vector<vector<unsigned long long> > d, tree;
void update(int l, int r, int k, int v, int i) {
  if (l + 1 == r) {
    tree[i][v] = d[i][k];
    return;
  }
  int m = (l + r) / 2;
  if (m > k)
    update(l, m, k, 2 * v + 1, i);
  else
    update(m, r, k, 2 * v + 2, i);
  tree[i][v] = tree[i][2 * v + 1] + tree[i][2 * v + 2];
  return;
}
unsigned long long findans(int l, int r, int lv, int rv, int v, int i) {
  if (l == lv && r == rv) {
    return tree[i][v];
  }
  int m = (l + r) / 2;
  if (rv <= m) return findans(l, m, lv, rv, 2 * v + 1, i);
  if (m <= lv) return findans(m, r, lv, rv, 2 * v + 2, i);
  return findans(l, m, lv, m, 2 * v + 1, i) +
         findans(m, r, m, rv, 2 * v + 2, i);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  d.resize(k + 2);
  tree.resize(k + 2);
  for (int i = 0; i < k + 2; i++) {
    d[i].resize(n + 1);
    tree[i].resize(4 * n + 4);
  }
  long long ans = 0;
  unsigned long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    x--;
    d[0][x]++;
    update(0, n, x, 0, 0);
    for (int j = 1; j <= k; j++) {
      d[j][x] += findans(0, n, 0, x, 0, j - 1);
      update(0, n, x, 0, j);
    }
  }
  for (int i = 0; i < n; i++) ans += d[k][i];
  cout << ans;
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 N = 300500;
int a[100500];
vector<vector<unsigned long long> > d, tree;
void update(int l, int r, int k, int v, int i) {
  if (l + 1 == r) {
    tree[i][v] = d[i][k];
    return;
  }
  int m = (l + r) / 2;
  if (m > k)
    update(l, m, k, 2 * v + 1, i);
  else
    update(m, r, k, 2 * v + 2, i);
  tree[i][v] = tree[i][2 * v + 1] + tree[i][2 * v + 2];
  return;
}
unsigned long long findans(int l, int r, int lv, int rv, int v, int i) {
  if (l == lv && r == rv) {
    return tree[i][v];
  }
  int m = (l + r) / 2;
  if (rv <= m) return findans(l, m, lv, rv, 2 * v + 1, i);
  if (m <= lv) return findans(m, r, lv, rv, 2 * v + 2, i);
  return findans(l, m, lv, m, 2 * v + 1, i) +
         findans(m, r, m, rv, 2 * v + 2, i);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  d.resize(k + 2);
  tree.resize(k + 2);
  for (int i = 0; i < k + 2; i++) {
    d[i].resize(n + 1);
    tree[i].resize(4 * n + 4);
  }
  long long ans = 0;
  unsigned long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    x--;
    d[0][x]++;
    update(0, n, x, 0, 0);
    for (int j = 1; j <= k; j++) {
      d[j][x] += findans(0, n, 0, x, 0, j - 1);
      update(0, n, x, 0, j);
    }
  }
  for (int i = 0; i < n; i++) ans += d[k][i];
  cout << ans;
  return 0;
}

```