#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int64_t n, k, c = 0;
  cin >> n >> k;
  int64_t a[n];
  for (auto& x : a) cin >> x;
  while (1) {
    int64_t p = 0, t = 0;
    for (int64_t i = 1; i < n; ++i)
      if (a[i] != a[i - 1] and a[i - 1] < k) a[i - 1] += 1, t = 1;
    if (a[n - 1] < k) a[n - 1]++, t = 1;
    if (t == 1) c++;
    for (int64_t i = 0; i < n; ++i)
      if (a[i] == k) p++;
    if (p == n) break;
  }
  cout << c;
}
