#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  Point operator / (long double k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double abs(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int ccw(Point p0, Point p1, Point p2) {
  Point v1 = p1 - p0, v2 = p2 - p0;
  if (cross(v1, v2) > 0) return 1;
  else if (cross(v1, v2) < 0) return -1;
  else if (dot(v1, v2) < 0) return 2;
  else if (norm(v1) < norm(v2)) return -2;
  else return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

long double getDistanceLP(Point p1, Point p2, Point p3) {
  return fabs(cross(p2-p1, p3-p1) / abs(p2-p1));
}

long double getDistanceSP(Point p1, Point p2, Point p3) {
  if (dot(p2-p1, p3-p1) < 0) return abs(p3-p1);
  else if (dot(p1-p2, p3-p2) < 0) return abs(p3-p2);
  else return getDistanceLP(p1, p2, p3);
}

long double getDistanceTS(Point p1, Point p2, Point p3, Point p4) {
  if (intersect(p1, p2, p3, p4)) return 0;
  long double ans = INF;
  ans = min(ans, getDistanceSP(p1, p2, p3));
  ans = min(ans, getDistanceSP(p1, p2, p4));
  ans = min(ans, getDistanceSP(p3, p4, p1));
  ans = min(ans, getDistanceSP(p3, p4, p2));
  return ans;
}

class Segment {
  public:
  Point p1, p2;
};

class EndPoint {
  public:
  Point p;
  int seg, st;
  EndPoint() {}
  EndPoint(Point p, int seg, int st): p(p), seg(seg), st(st) {}

  bool operator < (const EndPoint &ep) const {
    if (p.y == ep.p.y) {
      return st < ep.st;
    }
    else return p.y < ep.p.y;
  }
};

vector<EndPoint> EP;

int manhattanIntersection(vector<Segment> S) {
  int n = S.size();

  rep(i, n) {
    if (S[i].p1.y == S[i].p2.y) {
      if (S[i].p1.x > S[i].p2.x) swap(S[i].p1, S[i].p2);
    }
    else if (S[i].p1.y > S[i].p2.y) swap(S[i].p1, S[i].p2);

    if (S[i].p1.y == S[i].p2.y) {
      EP.push_back(EndPoint(S[i].p1, i, 1));
      EP.push_back(EndPoint(S[i].p2, i, 2));
    }
    else {
      EP.push_back(EndPoint(S[i].p1, i, 0));
      EP.push_back(EndPoint(S[i].p2, i, 3));
    }
  }

  sort(EP.begin(), EP.end());

  set<int> BT;
  BT.insert(INF);
  int cnt = 0;

  rep(i, 2 * n) {
    if (EP[i].st == 3) {
      BT.erase(EP[i].p.x);
    }
    else if (EP[i].st == 0) {
      BT.insert(EP[i].p.x);
    }
    else if (EP[i].st == 1) {
      set<int>::iterator b = lower_bound(BT.begin(), BT.end(), S[EP[i].seg].p1.x);
      set<int>::iterator e = upper_bound(BT.begin(), BT.end(), S[EP[i].seg].p2.x);
      cnt += distance(b, e);
    }
  }

  return cnt;
}

int main() {
  int n;
  cin >> n;
  Segment s;
  vector<Segment> S;
  rep(i, n) {
    cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
    S.push_back(s);
  }

  cout << manhattanIntersection(S) << endl;


  
  return 0;
}


Measured memory_bytes: 33648