#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
int main() {
  int n, k, t;
  scanf("%d%d", &n, &k);
  map<int, int> mii[2];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &t);
    if (t >= k) continue;
    if (mii[0].find(t) == mii[0].end())
      mii[0][t] = 1;
    else
      ++mii[0][t];
  }
  int pre = 0, cur = 1, key = 0;
  while (!mii[pre].empty()) {
    ++key;
    mii[cur].clear();
    for (map<int, int>::iterator mit = mii[pre].begin(); mit != mii[pre].end();
         ++mit) {
      if (mit->second == 1) {
        if (mit->first + 1 == k) continue;
        if (mii[cur].find(mit->first + 1) == mii[cur].end())
          mii[cur][mit->first + 1] = 1;
        else
          mii[cur][mit->first + 1]++;
      } else {
        if (mii[cur].find(mit->first) == mii[cur].end())
          mii[cur][mit->first] = mit->second - 1;
        else
          mii[cur][mit->first] += mit->second - 1;
        if (mit->first + 1 == k) continue;
        if (mii[cur].find(mit->first + 1) == mii[cur].end())
          mii[cur][mit->first + 1] = 1;
        else
          mii[cur][mit->first + 1]++;
      }
    }
    swap(cur, pre);
  }
  printf("%d\n", key);
  return 0;
}
