#include <bits/stdc++.h>
using namespace std;
int freq[1000001];
void solve() {
  int n, k;
  set<int> s;
  cin >> n >> k;
  int arr[n], steps = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s.insert(arr[i]);
    freq[arr[i]]++;
  }
  while (arr[0] != k) {
    for (int i = 0; i < n - 1; i++) {
      if (arr[i] != arr[i + 1]) {
        arr[i]++;
      }
    }
    if (arr[n - 1] < k) arr[n - 1]++;
    steps++;
  }
  cout << steps << endl;
}
signed main() { solve(); }
