#include <bits/stdc++.h>
using namespace std;
int a[1000050];
vector<int> vec[1000050];
int pos[1000050];
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    vec[a[i]].push_back(i);
  }
  pos[x + 1] = n;
  int st = 1;
  for (int i = x; i; i--) {
    pos[i] = pos[i + 1];
    if (vec[i].size()) {
      if (vec[i].back() < pos[i]) {
        pos[i] = vec[i][0];
      } else {
        st = i + 1;
        break;
      }
    }
  }
  int cur = -1;
  long long res = 0;
  for (int i = 1; i <= x; i++) {
    int p = lower_bound(pos + st, pos + x + 1, cur) - pos;
    p = max(p, i + 1);
    res += (x - p + 2);
    if (p == i) res--;
    if (vec[i].size()) {
      if (cur < vec[i][0])
        cur = vec[i].back();
      else
        break;
    }
  }
  printf("%lld\n", res);
  return 0;
}
