#include <bits/stdc++.h>
using namespace std;
int n, k, x;
long long t[15][400005];
long long get(int idx, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[idx][v];
  int tm = (tl + tr) / 2;
  return get(idx, v + v, tl, tm, l, min(r, tm)) +
         get(idx, v + v + 1, tm + 1, tr, max(l, tm + 1), r);
}
void update(int idx, int v, int tl, int tr, int pos, long long val) {
  if (tl == tr)
    t[idx][v] = val;
  else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(idx, v + v, tl, tm, pos, val);
    else
      update(idx, v + v + 1, tm + 1, tr, pos, val);
    t[idx][v] = t[idx][v + v] + t[idx][v + v + 1];
  }
}
int main() {
  scanf("%d%d", &n, &k);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    --x;
    update(1, 1, 0, n - 1, x, 1);
    for (int j = 2; j <= k + 1; ++j)
      update(j, 1, 0, n - 1, x, get(j - 1, 1, 0, n - 1, 0, x - 1));
  }
  for (int i = 0; i < n; ++i) ans += get(k + 1, 1, 0, n - 1, i, i);
  cout << ans;
  return 0;
}

### Prompt

Your challenge is to write 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, x;
long long t[15][400005];
long long get(int idx, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[idx][v];
  int tm = (tl + tr) / 2;
  return get(idx, v + v, tl, tm, l, min(r, tm)) +
         get(idx, v + v + 1, tm + 1, tr, max(l, tm + 1), r);
}
void update(int idx, int v, int tl, int tr, int pos, long long val) {
  if (tl == tr)
    t[idx][v] = val;
  else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(idx, v + v, tl, tm, pos, val);
    else
      update(idx, v + v + 1, tm + 1, tr, pos, val);
    t[idx][v] = t[idx][v + v] + t[idx][v + v + 1];
  }
}
int main() {
  scanf("%d%d", &n, &k);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    --x;
    update(1, 1, 0, n - 1, x, 1);
    for (int j = 2; j <= k + 1; ++j)
      update(j, 1, 0, n - 1, x, get(j - 1, 1, 0, n - 1, 0, x - 1));
  }
  for (int i = 0; i < n; ++i) ans += get(k + 1, 1, 0, n - 1, i, i);
  cout << ans;
  return 0;
}

```