#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point {
    double x, y;

    Point(double x = 0, 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*(double a) { return Point(a * x, a * y); }

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

    double abs() { return sqrt(norm()); }

    double norm() { return x * x + y * y; }

    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;
    }
};

typedef Point Vector;
typedef vector<Point> Polygon;


static const int IN = 2;
static const int ON = 1;
static const int OUT = 0;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;   // p2->p0->p1
static const int ONLINE_FRONT = -2; // p0->p1->p2
static const int ON_SEGMENT = 0;    // p0->p2->p1

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

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if (cross(a, b) < -EPS) return CLOCKWISE;
    if (dot(a, b) < -EPS) return ONLINE_BACK;
    if (norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

Polygon f(Polygon g) {
    Polygon u, l;
    if (g.size() < 3) return g;
    sort(g.begin(), g.end());
    u.push_back(g[0]);
    u.push_back(g[1]);
    l.push_back(g[g.size() - 1]);
    l.push_back(g[g.size() - 2]);

    // upper
    for (int i = 2; i < g.size(); i++) {
        for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], g[i]) == COUNTER_CLOCKWISE; n--) {
            u.pop_back();
        }
        u.push_back(g[i]);
    }

    // lower
    for (int i = g.size() - 3; i >= 0; i--) {
        for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], g[i]) == COUNTER_CLOCKWISE; n--) {
            l.pop_back();
        }
        l.push_back(g[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}


double abs(Point a) {
    return sqrt(norm(a));
}


double getDistance(Point a, Point b) {
    return abs(a - b);
}


double convexDiameter(Polygon g) {
    double d = 0.0;
    int n = g.size();
    int is = 0, js = 0;
    for (int i = 1; i < n; i++) {
        if (g[i].y > g[is].y) is = i;
        if (g[i].y < g[js].y) js = i;
    }
    d = getDistance(g[is], g[js]);

    int i = is, j = js, maxi = is, maxj = js;
    do {
        if (cross(g[(i + 1) % n] - g[i], g[(j + 1) % n] - g[j]) >= 0.0) j = (j + 1) % n;
        else i = (i + 1) % n;
        if (getDistance(g[i], g[j]) > d) {
            d = getDistance(g[i], g[j]);
            maxi = i, maxj = j;
        }
    } while (i != is || j != js);

    return d;
}

struct Segment {
    Point p1, p2;

    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};

typedef Segment Line;

bool isParallel(Vector a, Vector b) {
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.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);
}

bool intersect(Segment s1, Segment s2) {
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}


Point getCrossPoint(Segment s1, Segment s2) {
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1 - s2.p1));
    double d2 = abs(cross(base, s1.p2 - s2.p1));
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}


Polygon andrewScan(Polygon g) {
    Polygon u, l;
    if (g.size() < 3) return g;
    sort(g.begin(), g.end());
    u.push_back(g[0]);
    u.push_back(g[1]);
    l.push_back(g[g.size() - 1]);
    l.push_back(g[g.size() - 2]);

    // upper
    for (int i = 2; i < g.size(); i++) {
        for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], g[i]) != CLOCKWISE; n--) {
            u.pop_back();
        }
        u.push_back(g[i]);
    }

    // lower
    for (int i = g.size() - 3; i >= 0; i--) {
        for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], g[i]) != CLOCKWISE; n--) {
            l.pop_back();
        }
        l.push_back(g[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}


double area(Polygon g) {
    if (g.size() < 3) return 0;
    int n = g.size();
    Point o(0.0, 0.0);
    double s = 0.0;
    for (int i = 0; i < n; i++) s += cross(g[i] - o, g[(i + 1) % n] - o);
    return abs(s) / 2.0;
}

const double INF = 1e10;

typedef pair<double, double> p;
p v[100000];

bool comp_y(p a, p b) {
    return a.second < b.second;
}

double closest_pair(p *a, int n) {
    if (n <= 1) return INF;

    int m = n / 2;
    double x = a[m].first;
    double d = min(closest_pair(a, m), closest_pair(a + m, n - m)); // x軸で区切られた範囲内での頂点対のみ考慮
    inplace_merge(a, a + m, a + n, comp_y); // ソート済みの[a, a+m)と[a+m, a+n)をy座標基準でマージ

    vector<p> b; // 直線 x = a[m].firstから距離d未満の点を入れる
    for (int i = 0; i < n; i++) {
        if (fabs(a[i].first - x) >= d) continue; // そもそもx座標の差がd以上の点は論外

        // bに入っている頂点を末尾から、y座標の差がd以上になるまで見ていく
        // y座標降順で見ていき、d以上離れた時点で打ち切り
        for (int j = 0; j < b.size(); j++) {
            double dx = a[i].first - b[b.size() - 1 - j].first;
            double dy = a[i].second - b[b.size() - 1 - j].second;
            if (dy >= d) break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }

        b.push_back(a[i]);
    }
    return d;
}


struct STsum{
private:
    int n;
    vector<int> dat;
public:
    STsum(int siz){
        n = 1;
        while(n < siz)   n *= 2;
        dat.resize(2*n-1, 0);
    }

    void update(int x, int val){
        x += (n-1);
        dat[x] += val;
        while(x > 0){
            x = (x-1)/2;
            dat[x] = dat[2*x+1]+dat[2*x+2];
        }
    }

    // focus on k-th node, who controls [l, r)
    int query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        if(a <= l && r <= b)    return dat[k];

        int lx = query(a, b, 2*k+1, l, (l+r)/2);
        int rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx+rx;
    }
};

int main(){
    int n;
    cin >> n;

    vector<int> xax, ax(n), ay(n), bx(n), by(n);
    for(int i = 0; i < n; i++){
        cin >> ax[i] >> ay[i] >> bx[i] >> by[i];
        xax.push_back(ax[i]);  xax.push_back(bx[i]);
    }
    sort(xax.begin(), xax.end());
    xax.erase(unique(xax.begin(),xax.end()),xax.end());
    auto f = [&](int val)->int{
        return lower_bound(xax.begin(),xax.end(),val)-xax.begin();
    };

    STsum seg(xax.size()+1);
    vector<pair<pair<int,int>, int>> vp;
    for(int i = 0; i < n; i++){
        if(ax[i] == bx[i]){
            vp.push_back({{min(ay[i],by[i]), 0}, i});
            vp.push_back({{max(ay[i],by[i]), 2}, i});
        }else if(ay[i] == by[i]){
            vp.push_back({{ay[i], 1}, i});
        }
    }
    sort(vp.begin(), vp.end());
    int ans = 0;
    for(auto p : vp){
        if(p.first.second == 0){
            seg.update(f(ax[p.second]), 1);
        }else if(p.first.second == 2){
            seg.update(f(ax[p.second]), -1);
        }else if(p.first.second == 1){
            ans += seg.query(f(min(ax[p.second],bx[p.second])), f(max(ax[p.second],bx[p.second]))+1);
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 9316