#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int delfac = 1, brt = 0, j = 0, i = 1, u = 0;
    long k, trbr = 4, prbr = 3, prprbr = 2;
    vector<int> vectr;
    cin >> k;
    while (k >=4)
    {
        while (trbr*prbr*prprbr/6 <= k)
        {
            trbr++;
            prbr++;
            prprbr++;
        }
        vectr.push_back(trbr - 1);
        k -= (trbr - 1)*(prbr - 1)*(prprbr - 1)/6;
        brt+= trbr - 1;
        trbr = 4;
        prbr = 3;
        prprbr = 2;
    }
    vectr.push_back(0);
    brt += k*3;
    cout << brt << "\n";
    int c = 0;
    for (int i = 0; vectr.size() > i; i++)
    {
        for (j ++; u < vectr[i]; c++)
        {
            cout << j << " " << c << "\n";
            u++;
        }
        u = 0;
    }
    j ++;
    for (c++; k > 0; k--)
    {
        for (int i = 0; i < 3; i++)
        {
            cout << j << " " << c << "\n";
            c++;
        }
        j++;
    }
    return 0;
}