#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[200010];
int e[1010][1010];
int main() {
  int n, i, j, maxx = -1;
  long long int cnt;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    e[a[i].first][a[i].second] = 1;
    maxx = max(a[i].first, maxx);
  }
  sort(a, a + n);
  cnt = 0;
  for (i = 0; i < n; i++) {
    for (j = a[i].first + 1; j <= maxx; j++) {
      int t = abs(a[i].first - j);
      if ((a[i].second + t <= 1000 && e[j][a[i].second + t] == 1)) cnt++;
      if ((a[i].second - t >= 0 && e[j][a[i].second - t] == 1)) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
