Compute the number of matches for the input pattern

Signed-off-by: Guilhem Pujol <guilhem.pujol@gmail.com>