#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int MAXV = 1000000;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    vector<char> present(MAXV + 1, 0);
    for (auto& x : a) {
        cin >> x;
        present[x] = 1;
    }

    int threshold = 0, distinctSeen = 0;
    for (int v = 1; v <= MAXV && distinctSeen < k; v++) {
        if (present[v]) {
            distinctSeen++;
            threshold = v;
        }
    }

    // N <= 200, so for every left end we can just extend the right end
    // one step at a time. Values are bounded by 10^6, so a plain
    // counting array indexed by value (reset only where it was
    // touched) is simpler and cheaper than a hash map.
    vector<int> cnt(MAXV + 1, 0);

    ll ans = 0;
    for (int l = 0; l < n; l++) {
        int have = 0;

        for (int r = l; r < n; r++) {
            if (a[r] <= threshold && cnt[a[r]]++ == 0) have++;
            if (have == k) ans++;
        }

        for (int r = l; r < n; r++) {
            if (a[r] <= threshold) cnt[a[r]] = 0;
        }
    }

    cout << ans << '\n';

    return 0;
}
