#include <cstdio>
#include <iostream>

using namespace std;

const int NMAX = 30000;

struct Chord{
   int a,b;
};

Chord chords[NMAX];

int n;

int main (){
//  freopen("chords.in","r",stdin);
  //freopen("chords.out","w",stdout);
  cin >> n;
  for (int i=0; i<n; i++) {
    double a,b;
    cin >> a >> b;
    int a_i = (a>0) ? a*1000+0.5 : -((-a)*1000+0.5);
    int b_i = (b>0) ? b*1000+0.5 : -((-b)*1000+0.5);
    chords[i].a = a_i;
    chords[i].b = b_i;
    if (chords[i].a > chords[i].b) {
      int t = chords[i].a;
      chords[i].a = chords[i].b;
      chords[i].b = t;
    }
  }
  int cnt=0;
  for(int i=0; i<n-1; i++)
    for(int j=i+1; j<n; j++) {
       if (chords[j].a<chords[i].a && chords[i].a<chords[j].b && chords[j].b<chords[i].b) cnt++;
       else
       if (chords[i].a<chords[j].a && chords[j].a<chords[i].b && chords[i].b<chords[j].b) cnt++;
    }
  cnt += n+1;

  cout << cnt << endl;

  return 0;
}
