#include <bits/stdc++.h>
using namespace std;
bool e[4010][4010];
int degree[4010];
int ev[2][4010];
int answer = 1000 * 1000 * 1000;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> ev[0][i] >> ev[1][i];
    degree[ev[0][i]]++;
    degree[ev[1][i]]++;
    e[ev[0][i]][ev[1][i]] = true;
    e[ev[1][i]][ev[0][i]] = true;
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (e[ev[0][i]][j] && e[ev[1][i]][j])
        answer = min(answer, (degree[j] + degree[ev[0][i]] + degree[ev[1][i]]));
    }
  }
  if (answer == 1e9)
    cout << -1 << endl;
  else
    cout << answer - 6 << endl;
  return 0;
}
