#include <iostream>
using namespace std;
/*报数*/
bool judge(int i)
{
if(i%7==0)return true;
while(i)
{
if(i%10==7)return true;
i/=10;
}
return false;
}
int main()
{
int n,nums[4]={0,0,0,0};
cin>>n;
for(int i=1;i<=n;i++)
{
if(judge(i))//跳过
{
nums[i%4]++;
n++;//跳过时,上限也要扩大,容易漏掉
}
}
for(int i=1;i<=3;i++)cout <<nums[i]<<endl;
cout <<nums[0]<<endl;
}