#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	if (N == 1) { cout << 0 << endl; return (0); }
	set<Pi> ans;
	for (int i = 0; i < N; i += 2) {
		for (int j = 1; j <= N; j += 3) {
			if (j == N) j -= 2;
			int p = i+1-(j&1);
			if (p < N) ans.emplace(p, j);
		}
	}
	for (int j = 2; j < N; j += 2) {
		ans.emplace(1, j);
	}
	
	set<Pi> validator;
	cout << ans.size() << endl;
	for (auto &v : ans) {
		cout << v.first << " " << v.second << el;
	}
	/*DEBUG
	bool flag[1005][1005] = {};
	function<int(int, int)> dfs = [&](int y, int x) -> int {
		int ret = 1 - ((y+x) & 1);
		if (flag[y][x]) return (0);
		cout << " " << y << " " << x << " " << ret << endl;
		flag[y][x] = true;
		for (int i = 0; i < 4; i++) {
			int ny = y + dy[i], nx = x + dx[i];
			if (nx < 0 || ny < 0 || ny >= N || nx >= N) continue;
			if ((ny + nx) % 2 == 0 || ans.count(Pi(ny, nx))) {
				ret += dfs(ny, nx);
			}
		}
		return (ret);
	};

	int dat = dfs(0, 0);
	if (ans.size() <= 170000 && dat == N*N/2 + (N&1)) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}
	cout << "validator.size() = " << dat << endl;
	*/
	return (0);
}