#include <bits/stdc++.h>
#include "a.h"
using namespace std;
int n;
const int N = 5005;
int tw[N][20], tr[N][20];
int cnt1[N], cnt2[N];
void weiw(int x) {
int ll = x;
while(x) {
tw[ll][++cnt1[ll]] = x % 2;
x /= 2;
}
// printf("\n\n");
return;
}
void weir(int x) {
int ll = x;
while(x) {
tr[ll][++cnt2[ll]] = x % 3;
x /= 3;
}
return;
}
int dao[N];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
weiw(i), weir(i);
// for(int k = 1; k <= cnt1[i]; k++) dao[k] = tw[i][k];
// for(int k = cnt1[i]; k >= 1; k--) tw[i][k] = dao[cnt1[i] - k + 1];
// for(int k = 1; k <= cnt2[i]; k++) dao[k] = tr[i][k];
// for(int k = cnt1[i]; k >= 1; k--) tr[i][k] = dao[cnt2[i] - k + 1];
}
// for(int i = 1; i <= n; i++) {
// printf("%d %d %d\n", i, cnt1[i], cnt2[i]);
// for(int k = 1; k <= cnt1[i]; k++) printf("%d", tw[i][k]);
// printf("\n");
// for(int k = 1; k <= cnt2[i]; k++) printf("%d", tr[i][k]);
// printf("\n");printf("\n");
// }
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
int flag = 0;
for(int k = 1; k <= min(cnt1[i], cnt1[j]); k++) {
if(tw[i][k] == 1 && tw[j][k] == 1) {
flag = 1;
break;
}
}
for(int k = 1; k <= min(cnt2[i], cnt2[j]); k++) {
if(tr[i][k] + tr[j][k] >= 3) {
flag = 1;
break;
}
}
if(!flag) ans++;
}
}
printf("%d\n", ans);
}