#include <iostream>
#include<string>
#include<vector>


int main()
{int t;
std::vector<int> a;
a.push_back(0);
std::vector<int>p;
std::cin>>t;
std::string n;
int j;
for(int i = 0;i<t;i++){
    std::cin>>n;
    int q = std::stoi(n);
    for(int j = 0;j<=q;j++){
std::string tr = std::to_string(j);
int s = tr.size();
int zbir = 1;
for(int vel = 0; vel < s; vel++){
    char e = tr[vel];

    int u =e - '0' ;
    zbir =  zbir * u;

}
bool dali = true;
for(int t = 0; t< a.size();t++){
    if(zbir != a[t]){
        continue;}
    else{
        dali = false;
    }


    }
    if(dali == true){
        a.push_back(zbir);
}else{
        continue;
    }

    }
    std::cout<<(a.size());
}

    return 0;
}