#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    vector<long long> v(3, 0);
    long long privr=1, diff=3, diff2=3;
    for(int i=3;i<846;i++)
    {
        v.push_back(privr);
        privr+=diff;
        diff+=diff2;
        diff2++;
    }
    int k=845, nmr=0;
    long long x=0, y=0;
    string resenje;
    while(n)
    {
        if(v[k]<=n)
        {
            n-=v[k];
            for(int i=0;i<k;i++)
            {
                resenje+=to_string(x)+" "+ to_string(y)+'\n';
                x++;
            }
            y++;
            nmr+=k;
        }
        else
        {
            k--;
        }
    }
    cout<<nmr<<endl<<resenje;
    return 0;
}