#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main() {
pair<int, int> nr[100001];
int mx = 0;
ifstream fin("distanta.in");
ofstream fout("distanta.out");
int n = 0;
while(cin >> nr[n].first) {
nr[n++].second = n;
}
sort(nr, nr + 1);
for(int i = 0; i < n; i++) {
int j = i + 1;
while(nr[i].first == nr[j].first) {
mx = max(mx, nr[j].second - nr[i].second);
j++;
}
}
cout << mx;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgIHBhaXI8aW50LCBpbnQ+IG5yWzEwMDAwMV07CiAgICBpbnQgbXggPSAwOwogICAgaWZzdHJlYW0gZmluKCJkaXN0YW50YS5pbiIpOwogICAgb2ZzdHJlYW0gZm91dCgiZGlzdGFudGEub3V0Iik7CiAgICBpbnQgbiA9IDA7CiAgICB3aGlsZShjaW4gPj4gbnJbbl0uZmlyc3QpIHsKICAgICAgICAgbnJbbisrXS5zZWNvbmQgPSBuOwogICAgfQogICAgc29ydChuciwgbnIgKyAxKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBpbnQgaiA9IGkgKyAxOwogICAgICAgIHdoaWxlKG5yW2ldLmZpcnN0ID09IG5yW2pdLmZpcnN0KSB7CiAgICAgICAgICAgICBteCA9IG1heChteCwgbnJbal0uc2Vjb25kIC0gbnJbaV0uc2Vjb25kKTsKICAgICAgICAgICAgaisrOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgbXg7Cn0K