#include <iostream>

using namespace std;

int main() {

	int n;
	cin >> n;
	int q;
	cin >> q;
	int a[n];
	int b[q], c[q];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < q; i++){
		cin >> b[i] >> c[i];
	}
	for(int i = 0; i < q; i++){
		int brojac = 1;
		for(int j = b[i]; j < c[i]; j++){
			for(int k = b[i]; k < c[i]; k++){
				if(a[j] == a[k])
				brojac++;
				}
			}
			if(brojac == (c[i] - b[i] + 1)){
				cout << 1 << endl;
			}
			else{
				cout << brojac - (c[i] - b[i] + 1) << endl;
			}
	}
	
	return 0;
}