import java.lang.*;
import java.io.*;
import java.util.*;
class Ideone
{
public static void solve
(Scanner sc,
PrintStream out
) { List<Integer> list = new ArrayList<>();
while (sc.hasNext()) list.add(sc.nextInt());
int[] places = new int[list.size()];
for (Integer i
: list
) ++places
[i
];
int a = 0, b = places.length - 1;
while (!(a == b || --places[list.get(a)] == 0)) ++a;
while (!(a == b || --places[list.get(b)] == 0)) --b;
out.println(b - a + 1);
}
{
Scanner sc
= new Scanner
(System.
in);
while (sc.hasNext()) {
Scanner scLine = new Scanner(sc.nextLine());
scLine.close();
}
sc.close();
}
}
aW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS5pby4qOwppbXBvcnQgamF2YS51dGlsLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIHNvbHZlKFNjYW5uZXIgc2MsIFByaW50U3RyZWFtIG91dCkgewoJCUxpc3Q8SW50ZWdlcj4gbGlzdCA9IG5ldyBBcnJheUxpc3Q8PigpOwoJCXdoaWxlIChzYy5oYXNOZXh0KCkpIGxpc3QuYWRkKHNjLm5leHRJbnQoKSk7CgkJCQoJCWludFtdIHBsYWNlcyA9IG5ldyBpbnRbbGlzdC5zaXplKCldOwoJCWZvciAoSW50ZWdlciBpIDogbGlzdCkgKytwbGFjZXNbaV07CgkJCgkJaW50IGEgPSAwLCBiID0gcGxhY2VzLmxlbmd0aCAtIDE7CgkJd2hpbGUgKCEoYSA9PSBiIHx8IC0tcGxhY2VzW2xpc3QuZ2V0KGEpXSA9PSAwKSkgKythOwoJCXdoaWxlICghKGEgPT0gYiB8fCAtLXBsYWNlc1tsaXN0LmdldChiKV0gPT0gMCkpIC0tYjsKCQkKCQlvdXQucHJpbnRsbihiIC0gYSArIDEpOwoJfQoJCglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTY2FubmVyIHNjID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCgkJd2hpbGUgKHNjLmhhc05leHQoKSkgewoJCQlTY2FubmVyIHNjTGluZSA9IG5ldyBTY2FubmVyKHNjLm5leHRMaW5lKCkpOwoJCQlzb2x2ZShzY0xpbmUsIFN5c3RlbS5vdXQpOwoJCQlzY0xpbmUuY2xvc2UoKTsKCQl9CgkJCgkJc2MuY2xvc2UoKTsKCX0KfQ==