#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, k = -1, x;
  bool bucket[300] = {false};
  cin >> p >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (k == -1 && bucket[x % p] == true) {
      k = i;
    } else {
      bucket[x % p] = true;
    }
  }
  cout << k;
}
