An array of numbers and favourite numbers are given. we have to find the number of sub arrays which includes all the favourite numbers atleast once.

Constraints:

Let size of NUMBERS array be N, and size of favourite numbers be K

1 <=N <= 10^6

1<=K<=N

EXAMPLE:

NUMBERS :{1,2,1,1,1,1}

Favourite Numbers: {1,1,2}

Answer: 7

Explanation:

(1,2,1) , (1,2,1,1), (1,2,1,1,1), (1,2,1,1,1,1), (2,1,1), (2,1,1,1), (2,1,1,1,1)

NUMBERS: 3 9 6 9 2 2 4

FAVOURITE NUMBERS: 4 9

ANSWER:

4

(3,9,6,9,2,2,4), (9,6,9,2,2,4) ,(6,9,2,2,4) , (9,2,2,4)

Any help would be highly appreciated.Sorry! I couldn't recall the every detail of the question