#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<bitset>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define loop(i,j,k) for (int i = j;i != -1; i = k[i])
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
#define ff first
#define ss second
#define mp(i,j) make_pair(i,j)
#define pb push_back
#define pii pair<int,LL>
#define in(x) scanf("%d", &x);
using namespace std;
typedef long long LL;
const int low(int x) { return x&-x; }
const double eps = 1e-4;
const int INF = 0x7FFFFFFF;
const int mod = 9973;
const int N = 1e5 + 10;
int n, m, f[N], g[N];
int main()
{
while (scanf("%d%d", &n, &m) != EOF)
{
rep(i, 1, 2016)
{
f[i] = n / 2016 + (n % 2016 >= i);
g[i] = m / 2016 + (m % 2016 >= i);
}
LL ans = 0;
rep(i, 1, 2016) rep(j, 1, 2016)
{
if (i*j % 2016) continue;
ans += 1LL * f[i] * g[j];
}
printf("%lld\n", ans);
}
return 0;
}