#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;

const int INF = 1000000001;

int main(){
  int n;
  vector<pair<int,pii> > event;
  set<int> list;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    if(y1==y2){
      event.push_back(make_pair(min(x1,x2),pii(-INF,y1)));
      event.push_back(make_pair(max(x1,x2),pii(INF,y1)));
    }else if(x1==x2){
      event.push_back(make_pair(x1,pii(min(y1,y2),max(y1,y2))));
    }
  }
  sort(event.begin(),event.end());
  int ans = 0;
  for(int i=0;i<event.size();i++){
    int y1 = event[i].second.first, y2 = event[i].second.second;
    if(y1==-INF) list.insert(y2);
    else if(y1==INF) list.erase(y2);
    else ans += distance(list.lower_bound(y1),list.upper_bound(y2));
  }
  printf("%d\n",ans);
  return 0;
}