#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int hjysb,hjydsb;
int dhw(int a,int b)
{
int i;
int ans=0;
int sg[10001];
memset(sg,0,sizeof(sg));
for(i=a;i<=b;i++)
{
if((i%4==0 && i%100!=0) || i%400==0)
{
sg[i]=i;
ans++;
}
}
printf("%d\n",ans);
for(i=1582;i<=3000;i++)
{
if(sg[i]!=0)
{
printf("%d ",sg[i]);
}
}
}
int main()
{
scanf("%d %d",&hjysb,&hjydsb);
printf("%d",dhw(hjysb,hjydsb));
return 0;
}