#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n, 0));
  vector<int> connect(n, 0);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    a[x - 1][y - 1] = a[y - 1][x - 1] = 1;
    connect[x - 1]++;
    connect[y - 1]++;
  }
  int best = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i][j]) {
        for (int k = j + 1; k < n; k++) {
          if (a[i][k] && a[j][k]) {
            best = min(best, connect[i] + connect[j] + connect[k]);
          }
        }
      }
    }
  }
  cout << (best == 1e9 ? -1 : best - 6);
}
