#include <bits/stdc++.h>
using namespace std;
vector<int> a[4100];
int mp[4100][4100];
int main() {
  int n, m, u, v, ans = INT_MAX;
  cin >> n >> m;
  memset(mp, 0, sizeof(mp));
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    mp[u][v] = 1, mp[v][u] = 1;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  bool flag = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < a[i].size(); j++) {
      int t = a[i][j];
      for (int k = 0; k < a[t].size(); k++)
        if (mp[a[t][k]][i]) {
          flag = 1;
          if (a[i].size() + a[t].size() + a[a[t][k]].size() < ans + 6)
            ans = a[i].size() + a[t].size() + a[a[t][k]].size() - 6;
        }
    }
  if (flag)
    cout << ans << endl;
  else
    cout << "-1\n";
  return 0;
}
