#include <bits/stdc++.h>
using namespace std;
int g[4000][4000];
int p[4000];
vector<pair<int, int>> e;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int f, t;
    cin >> f >> t;
    f--, t--;
    e.push_back(make_pair(f, t));
    p[f]++;
    p[t]++;
    g[f][t] = g[t][f] = 1;
  }
  int ans = 1e9;
  for (int i = 0; i < e.size(); i++) {
    int f = e[i].first, s = e[i].second;
    for (int j = 0; j < n; j++) {
      int now = p[f] + p[s];
      if (g[j][f] == 1 && g[j][s] == 1) {
        now += p[j];
        now -= 3 + 3;
        ans = min(ans, now);
      }
    }
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
  return 0;
}
