#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 1e5 + 10, maxk = 15;
long long seg[4 * maxn][maxk], dp[maxk], a[maxn], k;
void sum(long long id, long long l, long long r, long long idx) {
  if (r == 0 || a[idx] <= l) {
    return;
  }
  if (r <= a[idx]) {
    for (long long i = 1; i < k + 1; i++) {
      dp[i] += seg[id][i - 1];
    }
    return;
  }
  long long mid = (l + r) / 2;
  sum(id * 2, l, mid, idx);
  sum(id * 2 + 1, mid, r, idx);
}
void add(long long id, long long l, long long r, long long idx) {
  if (l > idx || idx >= r) {
    return;
  }
  if (l + 1 == r) {
    for (long long i = 0; i < k + 1; i++) {
      seg[id][i] += dp[i];
    }
    return;
  }
  long long mid = (l + r) / 2;
  add(id * 2, l, mid, idx);
  add(id * 2 + 1, mid, r, idx);
  for (long long i = 0; i < k + 1; i++) {
    seg[id][i] = seg[id * 2][i] + seg[id * 2 + 1][i];
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, ans = 0;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    sum(1, 0, n, i);
    add(1, 0, n, a[i]);
    ans += dp[k];
  }
  cout << ans << endl;
}

### Prompt

In CPP, your task is to solve 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;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 1e5 + 10, maxk = 15;
long long seg[4 * maxn][maxk], dp[maxk], a[maxn], k;
void sum(long long id, long long l, long long r, long long idx) {
  if (r == 0 || a[idx] <= l) {
    return;
  }
  if (r <= a[idx]) {
    for (long long i = 1; i < k + 1; i++) {
      dp[i] += seg[id][i - 1];
    }
    return;
  }
  long long mid = (l + r) / 2;
  sum(id * 2, l, mid, idx);
  sum(id * 2 + 1, mid, r, idx);
}
void add(long long id, long long l, long long r, long long idx) {
  if (l > idx || idx >= r) {
    return;
  }
  if (l + 1 == r) {
    for (long long i = 0; i < k + 1; i++) {
      seg[id][i] += dp[i];
    }
    return;
  }
  long long mid = (l + r) / 2;
  add(id * 2, l, mid, idx);
  add(id * 2 + 1, mid, r, idx);
  for (long long i = 0; i < k + 1; i++) {
    seg[id][i] = seg[id * 2][i] + seg[id * 2 + 1][i];
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, ans = 0;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    sum(1, 0, n, i);
    add(1, 0, n, a[i]);
    ans += dp[k];
  }
  cout << ans << endl;
}

```