/* [Transfer]
*
* D [I] [J] indicates that when the first I object is attached, the equilibrium degree is J.
* (J> 0 indicates the weight on the left, j = 0 indicates the balance of the balance, and j <0 indicates the weight on the right) indicates the number of failures,
* Based on the question, the value range of J can be [-,]. Therefore, the state transition equation is as follows:
* D [I] [J] + = (d [I-1] [J-weigh [k] * POS [I]),
* Weigh [k] indicates the position of the K hook. Pos [I] indicates the weight of the I weight.
* Because j-weigh [k] * POS [I] may be negative, 7500 is added,
* The initial state d [0] [7500] = 1 (the balance at this time) indicates that there is no need for an object and there is only one method for balancing the balance.
*
*
*/
# Include <cstdio>
# Include <cstring>
Using namespace STD;
Const int max1 = 7500, max2 = 50;
Int C, G, weigh [max2], POS [max2], d [max2] [max1 * 2];
Int main (){
Scanf ("% d", & C, & G );
For (INT I = 1; I <= C; I ++)
Scanf ("% d", & Pos [I]);
For (INT I = 1; I <= g; I ++)
Scanf ("% d", & welap [I]);
Memset (D, 0, sizeof (d ));
D [0] [max1] = 1;
For (INT I = 1; I <= g; I ++ ){
For (Int J = 0; j <= max1 * 2; j ++)
For (int K = 1; k <= C; k ++)
D [I] [J] + = d [I-1] [J-weigh [I] * POS [k];
}
Printf ("% d \ n", d [g] [max1]);
Return 0;
}