#include <bits/stdc++.h>
using namespace std;
vector<int> g[5000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());
  int ans = INT_MAX, sum;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      int v1 = g[i][j];
      for (int k = j + 1; k < g[i].size(); k++) {
        int v2 = g[i][k];
        bool f1 = binary_search(g[v1].begin(), g[v1].end(), v2);
        bool f2 = binary_search(g[v2].begin(), g[v2].end(), v1);
        if (f1 && f2) {
          sum = (g[i].size() + g[v1].size() + g[v2].size()) - 6;
          ans = min(ans, sum);
        }
      }
    }
  }
  if (ans == INT_MAX)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}
