#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
int main()
{
cin>>n;
int ans = 0;
double mid = n * 1.0 / 2;
for (int i = 1; i < n; i ++ )
{
if((i*i)%n < mid)
{
ans++;
//cout<<i<<endl;
}
}
cout<<ans<<endl;
return 0;
}