WILDCARDS MATCHING

Program

WILDC.PAS, WILDC.C, WILDC.CPP


In everyday live we often use wildcards when e.g. searching strings in a file (ra?unalnik) or specify a set of filenames (*.txt). Typically, when specifying wildcard strings, two special charactes are used:
'*' matching zero or more charactes and '?' matching any single character.

Examples of matching:

  data string         wildcard string

  abcdefg      =       abcdefg
  abcdefg      =       abc*
  abcdefg      =       abc?efg
  abcdefgh     =       ab?*e*f?h
  abcdefgh     =       *
  abcdefg      =       ???????

The task is to write a program counting the number of successful matches between strings and wildcards.

Input Data

The file WILDC.IN contains in the first line integer N.
In the following 2*N lines are pairs of data-string and wildcard-string.

Output Data

The first and the only line of WILDC.OUT contains the number of sucessful matched pairs (data-string, wildcard-string).

Sample Input and Output


Input:

3
data-string wildcard-string
*string*string
Incorrect Example
????????????????
a
a

Output:

2