#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[1000];
  int b[1000];
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  int ans = 0;
  while (1) {
    int count = 0;
    for (int i = n; i >= 1; i--) {
      if (a[i] == k) ++count;
    }
    if (count == n) break;
    int f = a[n];
    for (int i = n; i >= 1; i--) {
      if (i == n) {
        if (a[n] < k) a[n] += 1;
      } else if (f > a[i]) {
        f = a[i];
        if (a[i] < k) a[i] = a[i] + 1;
      }
    }
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
