#include <iostream>
#include <algorithm>
using namespace std;
const int LEN = 34 + 5;
int a, b, n;
long long ans;
int m[LEN] = {0, 990, 1010, 1970, 2030, 2940, 3060, 3930, 4060, 4970, 5030, 5990, 6010, 7000};
void dfs(int dis)
{
if (7000 - dis <= a)
{
ans++;
return;
}
for (int i = 1; i <= n + 14; ++i)
{
if (m[i] >= dis + a && m[i] <= dis + b)
{
dfs(m[i]);
}
else if (m[i] < dis + a)
{
continue;
}
else
{
break;
}
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> a >> b >> n;
for (int i = 15; i <= n + 14; ++i)
{
cin >> m[i];
}
sort(m + 1, m + 15 + n, less<int>());
dfs(0);
cout << ans;
return 0;
}