## https://yukicoder.me/problems/no/2796 MAX_INT = 10 ** 18 def main(): N = int(input()) rR = [] for _ in range(N): r, R = map(int, input().split()) rR.append((r, R)) rR.sort(key=lambda x : x[0], reverse=True) ans = 0 min_r = MAX_INT for r, R in rR: if min_r >= R: ans += 1 min_r = r print(N - ans) if __name__ == "__main__": main()