#include <bits/stdc++.h>
using namespace std;
int edges[4010][4010];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> nodes(n + 1, 0), degree(n + 1, 0);
  vector<pair<int, int> > edgeList;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    nodes[a] = 1;
    nodes[b] = 1;
    edges[a][b] = 1;
    edges[b][a] = 1;
    degree[a]++;
    degree[b]++;
    edgeList.push_back(make_pair(a, b));
  }
  int ans = 100000;
  for (int i = 0; i < edgeList.size(); i++) {
    pair<int, int> edge = edgeList[i];
    int end1 = edge.first, end2 = edge.second;
    for (int j = 1; j <= n; j++) {
      if (j == end1 || j == end2) continue;
      if (edges[end1][j] == 1 && edges[end2][j] == 1) {
        ans = min(ans, degree[end1] + degree[end2] + degree[j]);
      }
    }
  }
  if (ans == 100000)
    cout << -1 << endl;
  else
    cout << ans - 6 << endl;
}
