#include #include #include #include #include #define MAX 128 #define M 1000000000 using namespace std; typedef long long i64; struct BigInterger { int d[MAX], n; BigInterger() : n(0) {} BigInterger(int x) : n(x ? 1 : 0) { d[0] = x; } BigInterger& operator +=(const BigInterger& o) { if (n < o.n) { for (int i = n; i < o.n; ++i) d[i] = 0; n = o.n; } int add = 0; for (int i = 0; i < o.n; ++i) { d[i] += o.d[i] + add; if (d[i] > M) { add = 1; d[i] -= M; } else { add = 0; } } for (int i = o.n; i < n; ++i) { d[i] += add; if (d[i] > M) { add = 1; d[i] -= M; } else { add = 0; } } if (add) { d[n++] = add; } return *this; } void Output() const { if (!n) printf("0"); else { printf("%d", d[n - 1]); for (int i = n - 2; i >= 0; --i) { printf("%9d", d[i]); } } } } dp[MAX][MAX]; int a[MAX]; void Solve(int n, int m, BigInterger* ret) { memset(dp, 0, sizeof(dp)); for (int i = 0; i <= m; ++i) dp[0][i] = 0; dp[0][1] = 1; *ret = dp[0][m]; for (int i = 1; i < n; ++i) { for (int j = 0; j <= m; ++j) dp[i][j] = 0; dp[i][1] = 1; for (int j = 2; j <= m; ++j) { for (int k = 0; k < i; ++k) { if (a[k] < a[i]) dp[i][j] += dp[k][j - 1]; } } *ret += dp[i][m]; } } int main() { int n, m; while (~scanf("%d%d", &n, &m)) { for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } BigInterger ret; Solve(n, m, &ret); ret.Output(); printf("\n"); } return 0; }