7403 - How much alike   

Description

Given two integer sequences A and B, with their values denoted by ai (1 ≤ iN) and bj (1 ≤ jM), we said that the sequence B matches A at index k, if there exists an integer d, such that ak + j = bj + d, 1 ≤ jM, k + jN. You have to count how many distinct k are there.

 

Input

Each test case begins with a line consists of two integers N and M (2 ≤ MN ≤ 50000), denoting the length of integer sequence A and B. The second line contains N integers ai (|ai| ≤ 108), and the third line contains M integers bj (|bj| ≤ 108).

The input is terminated by N = M = 0.

 

Output

For each test case, output a line that consists of an integer, denoting the number of matches.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss