#include <bits/stdc++.h>
using namespace std;
struct Square {
  int col, num = 0;
} square[1001];
int val;
set<int> s;
int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  while (m--) {
    cin >> val;
    square[val].num += 1;
    s.insert(val);
    if (s.size() == n) {
      sum += 1;
      for (int i = 1; i <= n; i++) square[i].num -= 1;
      for (int i = 1; i <= n; i++) {
        if (square[i].num == 0) s.erase(i);
      }
    }
  }
  cout << sum << endl;
  return 0;
}
