#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int main(){
    int N;
    cin >> N;
    vector<string>V(N);
    rep(i,0,N){

        rep(j,0,N){
            V[i].push_back((i+j)%2 ? '_' : '@');
        }
    }
    vector<int> A,B;
    int cnt = 0;
    rep(j,0,N){
        if(j % 3 != 1)continue;
        rep(i,0,N){
            if(j % 6 == 1 && i % 2 == 0 ||
               j % 6 == 4 && i % 2 == 1){
            cnt++;
            V[i][j] = '@';
            }
        }
    }
    rep(i,0,N){
        if(V[i][0] != '@'){
            cnt++;
            V[i][0] = '@';
        }
        if(V[i][N-1] != '@'){
            cnt++;
            V[i][N-1] = '@';
        }
    }
    rep(j,0,N){
        if(V[0][j] != '@'){
            cnt++;
            V[0][j] = '@';
        }
        if(V[N-1][j] != '@'){
            cnt++;
            V[N-1][j] = '@';
        }
    }
    //rep(i,0,N)cout << V[i] << endl;
    cout << cnt << endl;
    rep(i,0,N)rep(j,0,N){
        if((i+j) % 2 && V[i][j] == '@'){
            cout << i << " " << j << endl;
        }
    }
}