Number of Subarrays That Match a Pattern II