#include <iostream>
using namespace std;
int cmmdc(int a, int b)
{
while(b!=0)
{
int r = a % b;
a = b;
b = r;
}
return a;
}
int main()
{
int n, sc = 0, pc = 1;
cin >> n;
while(n)
{
sc += n % 10;
pc *= n % 10;
n /= 10;
}
cout<<cmmdc(sc, pc);
return 0;
}