#include <bits/stdc++.h>
using namespace std;
long long n, x[2], y[2], res;
struct line {
  long long s, a, b;
};
vector<line> dir1, dir2;
bitset<5002> B[5001];
bool is_cut(line x, line y) {
  return x.a <= y.s && y.s <= x.b && y.a <= x.s && x.s <= y.b;
}
void Solve() {
  cin >> n;
  for (long long j = 1, _b = n; j <= _b; j++) {
    for (long long i = 0, _b = 2; i < _b; i++) cin >> x[i] >> y[i];
    if (x[0] == x[1])
      dir1.push_back({x[0], min(y[0], y[1]), max(y[0], y[1])});
    else
      dir2.push_back({y[0], min(x[0], x[1]), max(x[0], x[1])});
  }
  if (dir1.size() > dir2.size()) swap(dir1, dir2);
  for (long long i = 0, _b = dir1.size(); i < _b; i++)
    for (long long j = 0, _b = dir2.size(); j < _b; j++) {
      B[i].set(j, is_cut(dir1[i], dir2[j]));
    }
  for (long long i = 0, _b = dir1.size(); i < _b; i++)
    for (long long j = 0, _b = i; j < _b; j++) {
      long long tmp = (B[i] & B[j]).count();
      res += tmp * (tmp - 1) / 2;
    }
  cout << res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}
