#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, val, count = 0;
  cin >> n >> m;
  vector<int> v(n, 0);
  while (m--) {
    cin >> val;
    v[val - 1]++;
    int c = 0, j;
    for (j = 0; j < n; j++) {
      if (v[j] == 0) {
        c = 1;
        break;
      }
    }
    if (c == 0) {
      count++;
      for (j = 0; j < n; j++) v[j] -= 1;
    }
  }
  cout << count;
  return 0;
}
