const fi=''; fo=''; var f:text; n,i,res:byte; c:char; a:array[1..4] of boolean; procedure readf; begin assign(f,fi); reset(f); readln(f,n); fillchar(a,sizeof(a),false); for i:=1 to n do begin read(f,c); if ord(c) in [48..57] then a[1]:=true; if ord(c) in [65..90] then a[2]:=true; if ord(c) in [97..122] then a[3]:=true; if (ord(c) in [33..47])and(ord(c)<>34)and(ord(c)<>39)and(ord(c)<>42)and(ord(c)<>44) then a[4]:=true; end; close(f); end; begin readf; assign(f,fo); rewrite(f); if n>=6 then begin res:=0; for i:=1 to 4 do if not a[i] then inc(res); end else if n=1 then res:=5 else begin res:=0; for i:=1 to 4 do if not a[i] then inc(res); if 6-n>=res then res:=6-n; end; write(f,res); close(f); end.