#include <bits/stdc++.h>
using namespace std;
vector<long long int> g[4005];
int gg[4005][4005];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(NULL);
  long long int n, m, x, y;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y;
    g[x - 1].push_back(y - 1);
    g[y - 1].push_back(x - 1);
    gg[x - 1][y - 1] = 1;
    gg[y - 1][x - 1] = 1;
  }
  long long int ans = 1e15;
  for (int i = 0; i <= n - 1; i++) {
    int nn = g[i].size();
    for (int j = 0; j < nn; j++) {
      int a = g[g[i][j]].size();
      for (int k = j + 1; k < nn; k++) {
        int b = g[g[i][k]].size();
        if (gg[g[i][j]][g[i][k]] == 1) {
          long long int c = 0;
          c += ((nn - 2) + (a - 2) + (b - 2));
          ans = min(ans, c);
        }
      }
    }
  }
  if (ans == 1e15) ans = -1;
  cout << ans;
  return 0;
}
