#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > graph;
vector<int> degree;
vector<pair<int, int> > edges;
int n, m, a, b;
void solve() {
  int result = INT_MAX;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; ++j) {
      if ((j != edges[i].first) && (j != edges[i].second)) {
        if (graph[edges[i].first][j] && graph[edges[i].second][j]) {
          result = min(result, degree[edges[i].first] + degree[j] +
                                   degree[edges[i].second]);
        }
      }
    }
  }
  if (result != INT_MAX)
    cout << (result - 6) << endl;
  else
    cout << "-1" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  graph.resize(n + 1);
  degree.resize(n + 1);
  edges.resize(m);
  for (int i = 1; i < n + 1; i++) graph[i].resize(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a][b] = 1;
    graph[b][a] = 1;
    ++degree[a];
    ++degree[b];
    edges[i] = make_pair(a, b);
  }
  solve();
  return 0;
}
