#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++){
		cout<<((2*i)%n)+1<<" "<<((2*i+1)%n)+1<<endl;
	}
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ll long long

#define pb        push_back

#define ppb       pop_back

#define pf        push_front

#define ppf       pop_front

#define all(x)    (x).begin(),(x).end()

#define uniq(v)   (v).erase(unique(all(v)),(v).end())

#define ff        first

#define ss        second

#define pii       pair<int,int>

#define vi        vector<int>

#define vpi       vector<pair<int,int>>

#define mii          map<int,int>

#define rep(i,a,b)   for(int i=a;i<b;i++)

#define repe(i,a,b)   for(int i=a;i<=b;i++)

#define mem1(a)      memset(a,-1,sizeof(a))

#define mem0(a)      memset(a,0,sizeof(a))

#define ppc          __builtin_popcount

#define ppcll        __builtin_popcountll

#define INF 100000000000000000

#define mod 1000000007

#define esp 10e-7

const int mx=1e5+7;
bool isseven(int n){
    
    while(n){
        if(n%10==7){
            return true;
        }
        n/=10;
    }
    return false;
}
bool isoctalseven(int n){
    while(n){
        if(n%8==7){
            return true;
        }
        n/=8;
    }
    return false;
}
int main(){

    int n;
    cin>>n;
    int m=7;
    unordered_set<int> st;
    // int c1=0;
    // while(m<=n){
    //     c1++;
    //     st.insert(m);
    //     m+=8;
    // }
    // cout<<c1;
    int c2=0;
    rep(i,1,n+1){
        if((isseven(i) )|| isoctalseven(i)){
            // cout<<i<<" ";
            c2++;
        }
    }
    cout<<n-(c2);

    return 0;

}