import java.io.*;
import java.util.*;
import java.net.*;
//_____________________________________________________________
public class mix
{ 
//_____________________________________________________________
public static final void main(String[] args) throws Exception
{
   mix bnk = new mix();
   bnk.start();
}
//_____________________________________________________________
mix() throws Exception 
{
}
//___________________________________________________________________________
void start()
{
   int cnt1 = 0;
   int cnt2 = 0;
   StringBuffer buf = new StringBuffer();
   String[] str = "1 9 5 3 5 3 1".split(" ");
   for (int i1 = 0; i1 < str.length; i1++)
   {
      buf.append(str[i1]);
      for (int i2 = 0; i2 < str.length; i2++)
      {
         boolean ok2 = true;
         if (i2 == i1) ok2 = false; 
         if (ok2)
         {
            buf.append(str[i2]);
            for (int i3 = 0; i3 < str.length; i3++)
            {
               boolean ok3 = true;
               if (i3 == i1) ok3 = false;
               if (i3 == i2) ok3 = false;
               if (ok3)
               {
                  buf.append(str[i3]);
                  for (int i4 = 0; i4 < str.length; i4++)
                  {
                     boolean ok4 = true;
                     if (i4 == i1) ok4 = false;
                     if (i4 == i2) ok4 = false;
                     if (i4 == i3) ok4 = false;
                     if (ok4)
                     {
                        buf.append(str[i4]);
                        for (int i5 = 0; i5 < str.length; i5++)
                        {
                           boolean ok5 = true;
                           if (i5 == i1) ok5 = false;
                           if (i5 == i2) ok5 = false;
                           if (i5 == i3) ok5 = false;
                           if (i5 == i4) ok5 = false;
                           if (ok5)
                           {
                              buf.append(str[i5]);
                              for (int i6 = 0; i6 < str.length; i6++)
                              {
                                 boolean ok6 = true;
                                 if (i6 == i1) ok6 = false;
                                 if (i6 == i2) ok6 = false;
                                 if (i6 == i3) ok6 = false;
                                 if (i6 == i4) ok6 = false;
                                 if (i6 == i5) ok6 = false;
                                 if (ok6)
                                 {
                                    buf.append(str[i6]);
                                    for (int i7 = 0; i7 < str.length; i7++)
                                    {
                                       boolean ok7 = true;
                                       if (i7 == i1) ok7 = false;
                                       if (i7 == i2) ok7 = false;
                                       if (i7 == i3) ok7 = false;
                                       if (i7 == i4) ok7 = false;
                                       if (i7 == i5) ok7 = false;
                                       if (i7 == i6) ok7 = false;
                                       if (ok7)
                                       {
                                          String s2 = str[i1] + str[i2] + str[i3] + str[i4] + str[i5] + str[i6] + str[i7];
                                          buf.append(str[i7]);
                                          long val = Long.parseLong(s2);
                                          cnt1++;
                                          if (cnt1 % 1000000 == 0) System.out.print(".");
                                          if (val % 27 == 0)
                                          {
                                             cnt2++;
                                          }
                                          System.out.println(cnt1 + " " + cnt2 + " " + val);
                                          buf = new StringBuffer();
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
       
         }
      }  
   }
   System.out.println(cnt1 + " " + cnt2);
}
}//__________________________________________________________________________
