from scipy.stats import kendalltau N = int(input()) x, y = map(list, zip(*[map(int, input().split()) for _ in range(N)])) print(kendalltau(x, y)[0])