#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj(4000);
int r[4000];
int main() {
  int n, mm;
  cin >> n >> mm;
  int ans = 5000;
  for (int i = 0; i < mm; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    r[a]++;
    r[b]++;
  }
  int m[3] = {0, 0, 0};
  for (int i = 0; i < n; i++) {
    m[0] = i;
    for (int& x : adj[i]) {
      m[1] = x;
      for (int& y : adj[i]) {
        bool f = false;
        for (int& z : adj[x])
          if (y == z) {
            f = true;
            break;
          }
        if (f) {
          m[2] = y;
          int aa = r[m[0]] + r[m[1]] + r[m[2]] - 6;
          if (aa < ans) ans = aa;
        }
      }
    }
  }
  if (ans == 5000)
    cout << -1;
  else
    cout << ans;
  return 0;
}
