#include<iostream>
using namespace std;
int main()
{
int n, res[4]={0};
cin >> n;
for (int i = 1; i < n+1; i++)
{
if (i%10 == 7 || i%7 == 0 || (i/10)%10 == 7 || (i/100)%10 == 7)
{
res[(i-1)%4]++;
n++;
}
}
for (int i = 0; i < 4; i++) cout << res[i] << endl;
return 0;
}
NOTE: Do not be n <= 666, without influence to judge whether the hundreds digit 7. Because the figure is not escape, so the number of possible number more than 700.