creating count letter function