#include <iostream>
using namespace std;
 
int main() {
	int n, x;
	cin >> n >> x;
	int minLen = n, position = -1;
	for (int i = 1; i <= n; ++i) {
		int currentEl;
		cin >> currentEl;
		if (currentEl == x) {
			if (position != -1 && i - position < minLen) {
				minLen = i - position;
			}
			position = i;
		}
	}
	cout << minLen;
	return 0;
}