#include <iostream>
using namespace std;
const int TEN = 10;
int main() {
int a;
cin >> a;
int copyA = a;
int reverseA = 0;
while (a) {
reverseA = reverseA * TEN + a % TEN;
a /= TEN;
}
int divizor = 2, estePrim = 1;
while (divizor < copyA) {
if (copyA % divizor == 0) {
estePrim = 0;
}
++divizor;
}
if (copyA == 1) {
estePrim = 0;
}
int divizorReverseA = 2, estePrimReverseA = 1;
while (divizorReverseA < reverseA) {
if (reverseA % divizorReverseA == 0) {
estePrimReverseA = 0;
}
++divizorReverseA;
}
if (reverseA == 1) {
estePrimReverseA = 0;
}
if ((estePrim == 1) && (estePrimReverseA == 1)) {
cout << "DA" << endl;
} else {
cout << "NU" << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IFRFTiA9IDEwOwoKaW50IG1haW4oKSB7CiAgICBpbnQgYTsKICAgIGNpbiA+PiBhOwogICAgaW50IGNvcHlBID0gYTsKICAgIGludCByZXZlcnNlQSA9IDA7CiAgICB3aGlsZSAoYSkgewogICAgICAgIHJldmVyc2VBID0gcmV2ZXJzZUEgKiBURU4gKyBhICUgVEVOOwogICAgICAgIGEgLz0gVEVOOwogICAgfQogICAgaW50IGRpdml6b3IgPSAyLCBlc3RlUHJpbSA9IDE7CiAgICB3aGlsZSAoZGl2aXpvciA8IGNvcHlBKSB7CiAgICAgICAgaWYgKGNvcHlBICUgZGl2aXpvciA9PSAwKSB7CiAgICAgICAgICAgIGVzdGVQcmltID0gMDsKICAgICAgICB9CiAgICAgICAgKytkaXZpem9yOwogICAgfQogICAgaWYgKGNvcHlBID09IDEpIHsKICAgICAgICBlc3RlUHJpbSA9IDA7CiAgICB9CiAgICBpbnQgZGl2aXpvclJldmVyc2VBID0gMiwgZXN0ZVByaW1SZXZlcnNlQSA9IDE7CiAgICB3aGlsZSAoZGl2aXpvclJldmVyc2VBIDwgcmV2ZXJzZUEpIHsKICAgICAgICBpZiAocmV2ZXJzZUEgJSBkaXZpem9yUmV2ZXJzZUEgPT0gMCkgewogICAgICAgICAgICBlc3RlUHJpbVJldmVyc2VBID0gMDsKICAgICAgICB9CiAgICAgICAgKytkaXZpem9yUmV2ZXJzZUE7CiAgICB9CiAgICBpZiAocmV2ZXJzZUEgPT0gMSkgewogICAgICAgIGVzdGVQcmltUmV2ZXJzZUEgPSAwOwogICAgfQogICAgaWYgKChlc3RlUHJpbSA9PSAxKSAmJiAoZXN0ZVByaW1SZXZlcnNlQSA9PSAxKSkgewogICAgICAgIGNvdXQgPDwgIkRBIiA8PCBlbmRsOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0IDw8ICJOVSIgPDwgZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9