#include <bits/stdc++.h>
using namespace std;
const int maxn = 100020;
const int MOd = 1e9 + 7;
int a, K;
int n, ar[maxn];
long long dn[12][maxn], segment[1 << 18];
long long find(int l, int r) {
  long long t = 0;
  for (l += n - 1, r += n - 1; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
    if (l & 1) t += segment[l];
    if (~r & 1) t += segment[r];
  }
  return t;
}
void up(int k, long long t) {
  for (k += n - 1; k; k >>= 1) segment[k] += t;
}
int main() {
  scanf("%d %d", &a, &K);
  K++;
  for (int i = 1; i <= a; i++) scanf("%d", &ar[i]);
  n = 1;
  while (n < a) n <<= 1;
  for (int i = 1; i <= a; i++) dn[0][i] = 1;
  for (int i = 1; i <= K; i++) {
    memset(segment, 0, sizeof(segment));
    for (int j = a; j >= 1; j--) {
      dn[i][j] = find(ar[j], a);
      up(ar[j], dn[i - 1][j]);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= a; i++) ans += dn[K - 1][i];
  cout << ans << endl;
  return 0;
}

### Prompt

Generate 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;
const int maxn = 100020;
const int MOd = 1e9 + 7;
int a, K;
int n, ar[maxn];
long long dn[12][maxn], segment[1 << 18];
long long find(int l, int r) {
  long long t = 0;
  for (l += n - 1, r += n - 1; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
    if (l & 1) t += segment[l];
    if (~r & 1) t += segment[r];
  }
  return t;
}
void up(int k, long long t) {
  for (k += n - 1; k; k >>= 1) segment[k] += t;
}
int main() {
  scanf("%d %d", &a, &K);
  K++;
  for (int i = 1; i <= a; i++) scanf("%d", &ar[i]);
  n = 1;
  while (n < a) n <<= 1;
  for (int i = 1; i <= a; i++) dn[0][i] = 1;
  for (int i = 1; i <= K; i++) {
    memset(segment, 0, sizeof(segment));
    for (int j = a; j >= 1; j--) {
      dn[i][j] = find(ar[j], a);
      up(ar[j], dn[i - 1][j]);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= a; i++) ans += dn[K - 1][i];
  cout << ans << endl;
  return 0;
}

```