#include <iostream>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
int main()
{
    set<long long> st;
    priority_queue<long long, vector<long long>, greater<long long>> pq;
    const int ok[3] = {3, 5, 7};
    st.insert(1);
    pq.push(1);
    int times = 0;
    while (true)
    {
        long long lucky = pq.top();
        pq.pop();
        if (lucky == 59084709587505)
        { //49
            cout << times << endl;
            return 0;
        }
        times++;
        for (int i = 0; i < 3; i++)
        {
            long long b = lucky * ok[i];
            if (!st.count(b))
            {
                st.insert(b);
                pq.push(b);
            }
        }
    }
    return 0;
}
