//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
const int inf = 1000000007, N=1005;
int TC = 1, CN, n;
pair<int, int> a[N];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        cin >> n;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i].fi >> a[i].se;
            for (int j = 0; j < i; j++) {
                ans += abs(a[i].se-a[j].se) <= abs(a[i].fi-a[j].fi);
            }
        }
        cout << ans << '\n';
    };
    while (CN++!=TC) kase();
}
#include <bits/stdc++.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    for(auto& [x, y] : A) cin >> x >> y;
    int ans = 0;
    for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) {
            auto [x1, y1] = A[i];
            auto [x2, y2] = A[j];
            if(abs(y1-y2) <= abs(x1-x2)) ans++;
        }
    cout << ans << endl;
}
