/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner s
=new Scanner
(System.
in); int N=s.nextInt();
int a[]=new int[N];
for(int i=0;i<N;i++){
a[i]=s.nextInt();
}
int k=s.nextInt();
HashMap
<Integer,Integer
> arr
=new HashMap
<>(); int si=0,ei=0,maxlen=0;
while(ei<N){
arr.put(a[ei],arr.getOrDefault(a[ei],0)+1);
while(arr.size()>k){
arr.put(a[si],arr.getOrDefault(a[si],0)-1);
if(arr.get(a[si])==0)
{
arr.remove(a[si]);
}
si++;
}
maxlen
=Math.
max(maxlen,
(ei
-si
)+1); ei++;
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgcz1uZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBOPXMubmV4dEludCgpOwoJCWludCBhW109bmV3IGludFtOXTsKCQlmb3IoaW50IGk9MDtpPE47aSsrKXsKCQkJYVtpXT1zLm5leHRJbnQoKTsKCQl9CgkJaW50IGs9cy5uZXh0SW50KCk7CgkJSGFzaE1hcDxJbnRlZ2VyLEludGVnZXI+IGFycj1uZXcgSGFzaE1hcDw+KCk7CgkJaW50IHNpPTAsZWk9MCxtYXhsZW49MDsKCQl3aGlsZShlaTxOKXsKCQkJCWFyci5wdXQoYVtlaV0sY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