Car Show
题号:NC240730
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

There are n cities and m car styles in NIO Kingdom. According to the investigations, for the i-th city, cars of style T_i are the most popular.

Now there will be a car show in NIO Kingdom, and the person in charge wants to choose an integer interval and let the cities whose indices are in this interval hold the show jointly. And to manifest the variety of the cars, every style should occur at least once among the most popular styles in the host cities. Determine the number of integer intervals satisfying the constraint mentioned before.

输入描述:

The first line contains two integers n and m , denoting the number of cities and the number of car styles respectively.

The second line contains n integers , denoting the most popular styles.

输出描述:

Output one line containing one integer, denoting the answer.
示例1

输入

复制
5 3
1 2 3 2 1

输出

复制
5

说明

For the sample case, the 5 intervals are [1, 3], [1, 4], [1, 5], [2, 5], [3, 5] respectively.