#include <iostream>
using namespace std;
int Legendre (int n, int a)
{
int cnt = 0;
int p = a;
while (p <= n)
{
cnt += n/a;
p *= a;
}
return cnt;
}
int main()
{
int n;
#include <iostream>
using namespace std;
int Legendre (int n, int a)
{
int cnt = 0;
int p = a;
while (p <= n)
{
cnt += n/a;
p *= a;
}
return cnt;
}
int main()
{
int n;