#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
long long c[20][N + 5], a[N + 5];
int n, k;
long long lowbit(long long x) { return x & (-x); }
void add(int t, long long x, long long w) {
  long long p = x;
  while (p <= n) {
    c[t][p] += w;
    p += lowbit(p);
  }
}
long long Sigma(int t, long long x) {
  long long p = x, ans = 0;
  while (p > 0) {
    ans += c[t][p];
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  while (~scanf("%d %d", &n, &k)) {
    memset(c, 0, sizeof(c));
    k++;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
      add(1, a[i], 1);
      for (int t = 2; t <= k; t++) {
        long long detal = Sigma(t - 1, a[i] - 1);
        add(t, a[i], detal);
      }
    }
    printf("%I64d\n", Sigma(k, n));
  }
  return 0;
}
