#include <bits/stdc++.h>
using namespace std;
int adj[4009][4009], d[4009];
vector<pair<int, int> > v;
int main() {
  int n, m;
  cin >> n >> m;
  int i, j;
  for (i = 0; i < m; ++i) {
    int a, b;
    scanf("%d", &a), scanf("%d", &b);
    ++adj[a][b];
    ++adj[b][a];
    v.push_back(make_pair(a, b));
    ++d[a], ++d[b];
  }
  int ans = INT_MAX;
  for (i = 0; i < v.size(); ++i) {
    int x = v[i].first;
    int y = v[i].second;
    for (j = 1; j <= n && j != x && j != y; ++j) {
      if (adj[j][x] == 1 && adj[j][y] == 1) {
        int r = d[x] + d[y] + d[j] - 6;
        ans = min(ans, r);
      }
    }
  }
  if (ans == INT_MAX)
    cout << "-1" << endl;
  else
    cout << ans << endl;
}
