#include<bits/stdc++.h>
using namespace std;
#define int long long
int a,b,n,ans;
int num[14]={0,990,1010,1970,2030,2940,3060,3930,4060,4970,5030,5990,6010,7000};
bool hotel[7050];
void s(int x){
if(x==7000){
ans++;
return ;
}
for(int i=x+a;i<=x+b;i++){
if(hotel[i]==1){
s(i);
}
}
}
signed main(){
cin>>a>>b>>n;
for(int i=0;i<14;i++) hotel[num[i]]=1;
for(int i=1;i<=n;i++){
int m;
cin>>m;
hotel[m]=1;
}
s(0);
cout<<ans;
return 0;
}