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

const int MAXA = 1000000;

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

    int N, K;
    cin >> N >> K;

    vector<int> a(N);
    vector<int> freq(MAXA + 1);

    for (int &x : a) {
        cin >> x;
        freq[x]++;
    }

    // K-те най-малки различни стойности
    vector<bool> important(MAXA + 1, false);
    int found = 0;

    for (int x = 1; x <= MAXA && found < K; x++) {
        if (freq[x] > 0) {
            important[x] = true;
            found++;
        }
    }

    long long ans = 0;

    for (int L = 0; L < N; L++) {
        for (int R = L; R < N; R++) {
            set<int> have;

            for (int i = L; i <= R; i++) {
                if (important[a[i]])
                    have.insert(a[i]);
            }

            if ((int)have.size() == K)
                ans++;
        }
    }

    cout << ans << '\n';
}
