#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkgewoJaW50IG4sIHg7CgljaW4gPj4gbiA+PiB4OwoJaW50IG1pbkxlbiA9IG4sIHBvc2l0aW9uID0gLTE7Cglmb3IgKGludCBpID0gMTsgaSA8PSBuOyArK2kpIHsKCQlpbnQgY3VycmVudEVsOwoJCWNpbiA+PiBjdXJyZW50RWw7CgkJaWYgKGN1cnJlbnRFbCA9PSB4KSB7CgkJCWlmIChwb3NpdGlvbiAhPSAtMSAmJiBpIC0gcG9zaXRpb24gPCBtaW5MZW4pIHsKCQkJCW1pbkxlbiA9IGkgLSBwb3NpdGlvbjsKCQkJfQoJCQlwb3NpdGlvbiA9IGk7CgkJfQoJfQoJY291dCA8PCBtaW5MZW47CglyZXR1cm4gMDsKfQ==