#include <bits/stdc++.h>
using namespace std;
vector <int> prime_factorization(int n) {
vector <int> temp;
for (int i = 2; i * 1LL * i<= n; ++i) {
while (n % i == 0) {
n /= i;
temp.push_back(i);
}
}
// cout << n << endl;
if (n > 1) temp.push_back(n);
return temp;
} // O( sqrt(n) )
const int N = 1e5 + 5;
vector <bool> isPrime;
vector <int> primes;
void sieve() {
isPrime.assign(N + 1, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i * i < N; i++) {
if (!isPrime[i]) continue;
for (int j = i * i; j < N; j += i) {
isPrime[j] = false;
}
}
for (int i = 2; i < N; ++i) {
if (isPrime[i]) {
primes.push_back(i);
}
}
}
vector <int> prime_fact(int n) {
vector <int> temp;
for (auto &x: primes) {
if ( x * x > n) break;
while (n % x == 0) {
n /= x;
temp.push_back(x);
}
}
if (n > 1) temp.push_back(n);
return temp;
} // O ( sqrt(n) / ln (sqrt(n)) ) ~ O (sqrt(n) / ln (n))
/// Prime number theorem: The number of primes less than or equal to n is approximately n / ln(n)
/// So, the number of primes less than or equal to sqrt(n) is approximately sqrt(n) / ln(sqrt(n)) = sqrt(n) / ln(n)
vector <pair<int,int>> prime_fact_pair(int n) {
vector <pair<int,int>> temp;
for (auto &x: primes) {
if ( x * x > n) break;
int cnt = 0;
while (n % x == 0) {
n /= x;
cnt++;
}
temp.push_back( {x, cnt} );
}
if (n > 1) temp.push_back( {n, 1} );
return temp;
} // O ( sqrt(n) / ln (sqrt(n)) ) ~ O (sqrt(n) / ln (n))
long long bigPow(int b, int e)
{
if (e == 0) return 1;
long long ret = bigPow(b, e / 2);
ret = ret * ret;
if (e & 1) ret = ret * b;
return ret;
}
int gcd(map<int,int> &mp1, map<int,int> &mp2) {
// vector<pair<int, int>> factors;
// for (auto &x: mp1) {
// if (mp2.count(x.first)) {
// factors.push_back( {x.first, min(x.second, mp2[x.first])} );
// }
// }
// int res = 1;
// for (auto &x: factors) {
// res *= bigPow(x.first, x.second);
// // cout << x.first << " " << x.second << endl;
// }
int res = 1;
for (auto &x: mp1) {
if (mp2.count(x.first)) {
res *= pow(x.first, min(x.second, mp2[x.first]));
}
}
return res;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
sieve();
auto vec1 = prime_fact(30);
auto vec2 = prime_fact(12);
map<int,int> mp1, mp2;
for (auto &x: vec1) mp1[x]++;
for (auto &x: vec2) mp2[x]++;
cout << gcd(mp1, mp2) << endl;
return 0;
}