import java.util.*;
import java.io.*;
/**
 * Write a description of class Problem1 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Pro4
{
    


    private static int sum (Integer input)
    {int ret=0;
        while (input>0)
        {
            ret+=input%10;
            input/=10;
        }
        return ret;
    }
        
    
    public static void main (String args[]) throws IOException
    {
        Scanner kb = new Scanner( new File("DATA4.txt"));
        PrintWriter xyz = new PrintWriter (new BufferedWriter (new FileWriter("OUT4.txt")));
        ArrayList <Integer> Dictionary = new ArrayList<Integer>();
        
        for (int x=0;x<50000;x++)
        {
            Dictionary.add((x*sum(x))%99999);
        }
        
        //System.out.println(Dictionary.get(12345));
        for (int a=0;a<5;a++)
        {
            int output=0;
            int  input= kb.nextInt();
            
            for (int x=0;x<50000;x++)
            {
                int dict= Dictionary.get(x);
                while(dict>0)
                {
                    if (dict==input)
                    output++;
                    dict/=10;
                }
            
           } 
           xyz.println(output);
        }
       xyz.close();
    }
       
    
}

