#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300 + 5;
int p, n, ind = -1;
bool mark[MAXN];
int main() {
  cin >> p >> n;
  for (int i = 0, tmp; i < n; i++) {
    cin >> tmp;
    if (!mark[tmp % p])
      mark[tmp % p] = true;
    else if (ind == -1)
      ind = i + 1;
  }
  cout << ind << endl;
  return 0;
}
