#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
const long double eps = 1e-12;
const long long mod = 1e9 + 7;
const int inf = INT_MAX;
int n, m;
vector<vector<char> > gr(0, vector<char>(0));
;
vector<int> sum;
vector<pair<int, int> > edges;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n >> m;
  gr.assign(n, vector<char>(n, 0));
  sum.assign(n, 0);
  for (long long i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    gr[u][v] = gr[v][u] = 1;
    ++sum[u];
    ++sum[v];
    edges.push_back(pair<int, int>(u, v));
  }
  int _min = inf;
  for (long long i = 0; i < m; ++i) {
    int u = edges[i].first, v = edges[i].second;
    for (long long j = 0; j < n; ++j) {
      if (gr[j][u] && gr[j][v]) _min = min(_min, sum[u] + sum[v] + sum[j] - 6);
    }
  }
  if (_min == inf)
    cout << -1;
  else
    cout << _min;
  return 0;
}
