var i,j,n,k,p:longint;
  s1,s,s3:string;
begin
  readln(s);
  readln(s1);
  s:=' '+s;  s3:=s1;
  for i:=1 to length(s1) do
  begin
    n:=1;

    p:=1;
    while n<length(s) do
    begin
    inc(n);
    if (s[n-1]='*')and(s[n]<>'*') then begin
    j:=pos(s[n],s3);if (n=length(s)) and(s3[length(s3)]=s[length(s)]) then j:=length(s3);
    if j=0 then begin p:=0; break end
    else delete(s3,1,j); end
    else if s[n]<>'*' then if s3[1]<>s[n] then begin
    p:=0; break; end else delete(s3,1,1);
    end;
    if ((s[n]='*')and(p=1))or((s3='')and(p=1)) then inc(k);
    s3:=s1[length(s1)]+s1;
    delete(s3,length(s1),1);
  end;
  writeln(k);

end.
