#include <iostream>
using namespace std;
bool isPowerOf3 (int n) {
// edge case
if (n <= 0) {
return false;
}
while(n % 3 == 0){
n /= 3;
}
return n == 1;
}
int main() {
int n;
cin>>n;
bool decision = isPowerOf3(n);
if(decision){
cout<<"True\n";
} else {
cout<<"False\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCiAKYm9vbCBpc1Bvd2VyT2YzIChpbnQgbikgewoJLy8gZWRnZSBjYXNlCglpZiAobiA8PSAwKSB7IAoJCXJldHVybiBmYWxzZTsKCX0KIAoJd2hpbGUobiAlIDMgPT0gMCl7CgkJbiAvPSAzOwoJfQogCglyZXR1cm4gbiA9PSAxOwp9CiAKaW50IG1haW4oKSB7CiAKCWludCBuOwoJY2luPj5uOwogCglib29sIGRlY2lzaW9uID0gaXNQb3dlck9mMyhuKTsKIAoJaWYoZGVjaXNpb24pewoJCWNvdXQ8PCJUcnVlXG4iOwoJfSBlbHNlIHsKCQljb3V0PDwiRmFsc2VcbiI7Cgl9CiAKIAoJcmV0dXJuIDA7Cn0=