This sounds a bit like a homework problem but I'll give a hint to use the functions count and filter
count
filter