#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

char s[1005][1005];
int main(void){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if((i+j)%2==0){
				s[i][j] = '#';
			}else{
				s[i][j] = '.';
			}
		}
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(s[i][0] =='.'){
			ans ++;
			s[i][0] = 'x';
		}
		if(s[0][i] =='.'){
			ans++;
			s[0][i] = 'x';
		}
		if(s[N-1][i] =='.'){
			ans++;
			s[N-1][i] = 'x';
		}
	}
	for(int i=1;i<N-1;i++)
		if(i%3==0){
			for(int j=0;j<N;j++){
				if(s[i][j] =='.'){
					ans++;
					s[i][j] = 'x';
				}
			}
		}
	
	cout << ans << endl;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++){
		if(s[i][j] =='x')cout << i << " " << j << endl;
	}
}