The Big Painting

Samuel W. E. R. Craft is an artist with a growing reputa- tion. Unfortunately, the paintings he sells do not provide him enough money for his daily expenses plus the new sup- plies he needs. He had a brilliant idea yesterday when he ran out of blank canvas: ”Why don’t I create a gigantic new painting, made of all the unsellable paintings I have, stitched together?”. After a full day of work, his master- piece was complete. That’s when he received an unexpected phone call: a client saw a photograph of one of his paintings and is willing to buy it now! He had forgotten to tell the art gallery to remove his old works from the catalog! He would usually welcome a call like this, but how is he going to find his old work in the huge figure in front of him? Galerie de Vues de la Rome Moderne, Panini (1759). What S.W.E.R.C. had in mind when he tried to merge his paintings. The input file contains several test cases, each of them as described below. The first line consists of 4 space-separated integers: hp wp hm wm, the height and width of the painting he needs to find, and the height and width of his masterpiece, respectively. The next hp lines have wp lower-case characters representing his painting. After that, the next hm lines have wm lower-case characters representing his masterpiece. Each character will be either ‘x’ or ‘o’. Constraints: 1≤hp,wp ≤2000 1≤hm,wm ≤2000 hp ≤ hm wp ≤ wm Output For each test case, output a single integer representing the number of possible locations where his painting might be, on a line by itself. Sample Output Explanation The painting could be in four locations as shown in the following picture. Two of the locations overlap. Given a black-and-white representation of his original painting and a black-and-white representation of his mas- terpiece, can you help S.W.E.R.C. identify in how many locations his painting might be? Input

2/2 Sample Input 4 4 10 10 oxxo xoox xoox oxxo xxxxxxoxxo oxxoooxoox xooxxxxoox xooxxxoxxo oxxoxxxxxx ooooxxxxxx xxxoxxoxxo oooxooxoox oooxooxoox xxxoxxoxxo Sample Output 4