#include <bits/stdc++.h>
using ll = long long;
using namespace std;
struct Point {
  int x, y;
};
istream& operator>>(istream& in, Point& p) { return in >> p.x >> p.y; }
ostream& operator<<(ostream& out, Point& p) {
  return out << '(' << p.x << ',' << p.y << ')';
}
struct Segment {
  Point a, b;
  int minX() const { return min(a.x, b.x); }
  int maxX() const { return max(a.x, b.x); }
  int minY() const { return min(a.y, b.y); }
  int maxY() const { return max(a.y, b.y); }
  void normal() {
    if (a.x > b.x) swap(a, b);
  }
  bool isVer() const { return a.x == b.x; }
  bool isIntersect(Segment const& s) const {
    return (isVer() != s.isVer()) &&
           (minX() <= s.maxX() && s.minX() <= maxX()) &&
           (minY() <= s.maxY() && s.minY() <= maxY());
  }
};
istream& operator>>(istream& in, Segment& s) {
  in >> s.a >> s.b;
  s.normal();
  return in;
}
ostream& operator<<(ostream& out, Segment& s) {
  return out << s.a << ' ' << s.b;
}
struct FT {
  int offset;
  int size;
  vector<int> buf;
  FT(int left, int right) : offset(-left), size(right - left + 10), buf(size) {}
  void add(int pos, int dv) {
    pos += offset;
    for (; pos < size; pos += pos & -pos) buf[pos] += dv;
  }
  int sum(int pos) {
    pos += offset;
    int sum = 0;
    for (; pos > 0; pos -= pos & -pos) sum += buf[pos];
    return sum;
  }
  int seg(int l, int r) { return sum(r) - sum(l - 1); }
};
const int N = 5001;
void solve() {
  int n;
  cin >> n;
  vector<Segment> a(n);
  vector<int> vi, hi;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i].isVer()) {
      vi.push_back(i);
    } else {
      hi.push_back(i);
    }
  }
  sort(vi.begin(), vi.end(), [&](int i, int j) { return a[i].a.x < a[j].a.x; });
  sort(hi.begin(), hi.end(), [&](int i, int j) { return a[i].b.x < a[j].b.x; });
  ll res = 0;
  FT ft(-5010, 5010);
  vector<int> ihind;
  for (int i = 0; i < vi.size(); ++i) {
    int vind = vi[i];
    for (int j = 0; j < hi.size(); ++j) {
      int hind = hi[j];
      if (a[vind].isIntersect(a[hind])) {
        ihind.push_back(hind);
        ft.add(a[hind].a.y, 1);
      }
    }
    reverse(ihind.begin(), ihind.end());
    for (int j = i + 1; j < vi.size(); ++j) {
      if (ihind.empty()) {
        break;
      }
      int vjnd = vi[j];
      int bx = a[vjnd].b.x;
      while (!ihind.empty() && bx > a[ihind.back()].b.x) {
        ft.add(a[ihind.back()].a.y, -1);
        ihind.pop_back();
      }
      if (ihind.empty()) {
        break;
      }
      int ymn = max(a[vind].minY(), a[vjnd].minY());
      int ymx = min(a[vind].maxY(), a[vjnd].maxY());
      ll cnt = ft.seg(ymn, ymx);
      res += cnt * (cnt - 1) / 2;
    }
    while (ihind.size()) {
      ft.add(a[ihind.back()].a.y, -1);
      ihind.pop_back();
    }
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
