#include <iostream>
#include <string>
using namespace std;
bool palindrome(int n) {
string s=to_string(n);
int x=s.length();
for (int i=0;i<=x/2;i++) {
if (s[i]!=s[x-i-1]) {
return false;
}
}
return true;
}
bool snt(int n) {
if (n<2) return false;
for (int i=2;i*i<=n;i++) {
if (n%i==0) {
return false;
}
}
return true;
}
int main () {
freopen("SO.INP","r",stdin);
freopen("SO.OUT","w",stdout);
int n;
cin >> n;
int d=0;
for (int i=1;i<=n;i++) {
if (palindrome(i) && snt(i)) {
d++;
}
}
cout << d;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYm9vbCBwYWxpbmRyb21lKGludCBuKSB7CiAgICBzdHJpbmcgcz10b19zdHJpbmcobik7CiAgICBpbnQgeD1zLmxlbmd0aCgpOwogICAgZm9yIChpbnQgaT0wO2k8PXgvMjtpKyspIHsKICAgICAgICBpZiAoc1tpXSE9c1t4LWktMV0pIHsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiB0cnVlOwp9Cgpib29sIHNudChpbnQgbikgewogICAgaWYgKG48MikgcmV0dXJuIGZhbHNlOwogICAgZm9yIChpbnQgaT0yO2kqaTw9bjtpKyspIHsKICAgICAgICBpZiAobiVpPT0wKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKfQoKaW50IG1haW4gKCkgewogICAgZnJlb3BlbigiU08uSU5QIiwiciIsc3RkaW4pOwogICAgZnJlb3BlbigiU08uT1VUIiwidyIsc3Rkb3V0KTsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBpbnQgZD0wOwogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKSB7CiAgICAgICAgaWYgKHBhbGluZHJvbWUoaSkgJiYgc250KGkpKSB7CiAgICAgICAgICAgIGQrKzsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGQ7Cn0K