CF652C Foe Pairs

Description

You are given a permutation $ p $ of length $ n $ . Also you are given $ m $ foe pairs $ (a_{i},b_{i}) $ ( $ 1

Input Format

The first line contains two integers $ n $ and $ m $ ( $ 1

Output Format

Print the only integer $ c $ — the number of different intervals $ (x,y) $ that does not contain any foe pairs. Note that the answer can be too large, so you should use $ 64 $ -bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Explanation/Hint

In the first example the intervals from the answer are $ (1,1) $ , $ (1,2) $ , $ (2,2) $ , $ (3,3) $ and $ (4,4) $ .