
var a:array[1..10000] of boolean;
    c:array[1..1000]of boolean;
    b:array[1..10000]of integer;
    max,n,m,k,d,min,last,konv,i,j:integer;
    buf: boolean;
Begin
assign(input,'B.in');reset(input);
assign(output,'B.out');rewrite(output);
read(n,m,k);
readln(d);
for i:=1 to d do
begin
  read(b[i]);
  c[b[i]]:=true;
end;
if n<m then min:=n else min:=m;

   last:=0;
   konv:=1;
   i:=0;


while (i<>min)do
begin
buf:=false;
   for j:=1 to d do
    begin
      if (b[j]<>0)and(a[last+b[j]]=false)then  buf:=true else buf:=false;
    end;
   if buf=true then
     begin
   for j:=1 to k do
    begin
      if (c[j]=true)and(a[last+j]=false)then begin a[last+j]:=true;end;
    end;
    inc(i);
     end;
    inc(last);
end;
max:=last+k-1;
writeln(max);



close(input);
close(output);
end.