#include<iostream>
using namespace std;int prime[30];int main(){int count=1;prime[0]=2;for(int i=3;i<100;i+=2){bool t=true;for(int j=1;j<count;j++){if(i%prime[j]==0)t=false;}if(t==true){prime[count]=i;count++;}}int n;while(cin>>n){n++;int ans=0;for(int cut=2;cut<n-1;cut++){bool t=true,f=true;for(int i=0;i<count;i++){if(cut%prime[i]==0&&cut!=prime[i])t=false;}for(int i=0;i<count;i++){if((n-cut)%prime[i]==0&&n-cut!=prime[i])f=false;}if(t==true&&f==true)ans++;}cout<<ans<<endl;}return 0;}