#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 100005;
typedef unsigned long long ull;
ull n;
int main(){
freopen("Hescircle.in","r",stdin);
freopen("Hescircle.out","w",stdout);
cin >> n;
ull ans = 0;
ans += pow(2,n);
for (int i = 1;i <= n-1;i++){
ans += pow(2,__gcd((ull)i,n));
}
ans /= n;
cout << ans << endl;
return 0;
}