#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;
        }
    }

    // Every target occurs exactly once, so a subarray contains all of
    // them iff it spans from at most the earliest target position to
    // at least the latest one. The count is simply
    // (choices for the left end) * (choices for the right end).
    int minPos = n, maxPos = -1;
    for (int i = 0; i < n; i++) {
        if (a[i] <= threshold) {
            minPos = min(minPos, i);
            maxPos = max(maxPos, i);
        }
    }

    ll leftChoices = minPos + 1;
    ll rightChoices = n - maxPos;

    cout << (leftChoices * rightChoices) << '\n';

    return 0;
}
