#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long u = 0; u < 30000; u++)
	{
		long long n = 0;
		cin >> n;
		if (n == 0)
		{
			break;
		}

		int co = 0;

		for (long long i = 1; i < n + 1; i++)
		{
			ostringstream p;
			p << i;
			string pp;
			pp = p.str();

			int k = 0;
			k = pp.size();

			for (int j = 0; j < k; j++)
			{
				if (pp.substr(j,1) == "4")
				{
					co += 1;
				}
				else if (pp.substr(j,1) == "6")
				{
					co += 1;
				}
			}
		}

		cout<< " "  << co << " "<< n + co << endl;
	}
}
