#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<bool> up_ing;
  vector<int> soldiers;
  int i, j, n, k, result;
  cin >> n >> k;
  soldiers.resize(n);
  up_ing.resize(n);
  for (i = 0; i < n; i++) cin >> soldiers[i];
  result = 0;
  while (soldiers[0] != k) {
    for (i = 0; i < n; i++) up_ing[i] = false;
    if (soldiers[n - 1] != k) up_ing[n - 1] = true;
    for (i = n - 1; i > 0; i--) {
      if (soldiers[i - 1] != soldiers[i]) up_ing[i - 1] = true;
    }
    for (i = 0; i < n; i++) {
      if (up_ing[i]) soldiers[i]++;
    }
    result++;
  }
  cout << result << endl;
  return 0;
}
