#include <bits/stdc++.h>
using namespace std;
struct SegTree {
 private:
  vector<long long> arr;
  int n;

 public:
  void init(int i) {
    n = i;
    arr.assign(n * 2, 0);
  }
  void update(int pos, long long value) {
    for (arr[pos += n] = value; pos > 1; pos >>= 1) {
      arr[pos >> 1] = arr[pos] + arr[pos ^ 1];
    }
  }
  long long query(int left, int right) {
    long long ans = 0;
    for (left += n, right += n; left < right; left >>= 1, right >>= 1) {
      if (left & 1) ans += arr[left++];
      if (right & 1) ans += arr[--right];
    }
    return ans;
  }
};
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  SegTree dp[12];
  for (int i = 0; i < 12; i++) {
    dp[i].init(n + 1);
  }
  for (int i = 0; i < n; i++) {
    int val;
    scanf("%d", &val);
    dp[0].update(val, 1);
    for (int j = 1; j <= k; j++) {
      dp[j].update(val, dp[j - 1].query(0, val));
    }
  }
  printf("%I64d\n", dp[k].query(0, n + 1));
  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;
struct SegTree {
 private:
  vector<long long> arr;
  int n;

 public:
  void init(int i) {
    n = i;
    arr.assign(n * 2, 0);
  }
  void update(int pos, long long value) {
    for (arr[pos += n] = value; pos > 1; pos >>= 1) {
      arr[pos >> 1] = arr[pos] + arr[pos ^ 1];
    }
  }
  long long query(int left, int right) {
    long long ans = 0;
    for (left += n, right += n; left < right; left >>= 1, right >>= 1) {
      if (left & 1) ans += arr[left++];
      if (right & 1) ans += arr[--right];
    }
    return ans;
  }
};
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  SegTree dp[12];
  for (int i = 0; i < 12; i++) {
    dp[i].init(n + 1);
  }
  for (int i = 0; i < n; i++) {
    int val;
    scanf("%d", &val);
    dp[0].update(val, 1);
    for (int j = 1; j <= k; j++) {
      dp[j].update(val, dp[j - 1].query(0, val));
    }
  }
  printf("%I64d\n", dp[k].query(0, n + 1));
  return 0;
}

```