#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int base, long long int exp, long long int M) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % M;
    base = (base * base) % M;
    exp >>= 1;
  }
  return res;
}
vector<long long int> par;
long long int root(long long int a) {
  while (a != par[a]) {
    par[a] = par[par[a]];
    a = par[a];
  }
  return a;
}
void unio(long long int a, long long int b) { par[root(a)] = root(b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  vector<vector<long long int> > graph(n + 1, vector<long long int>(n + 1));
  vector<long long int> deg(n + 1);
  for (long long int i = 0; i <= m - 1; ++i) {
    long long int u, v;
    cin >> u >> v;
    graph[u][v] = 1;
    graph[v][u] = 1;
    deg[v]++;
    deg[u]++;
  }
  long long int ans = INT_MAX;
  for (long long int i = 1; i <= n; ++i) {
    for (long long int j = i + 1; j <= n; ++j) {
      if (graph[i][j]) {
        for (long long int k = j + 1; k <= n; ++k) {
          if (graph[i][k] && graph[j][k])
            ans = min(ans, deg[i] + deg[j] + deg[k]);
        }
      }
    }
  }
  if (ans == INT_MAX)
    cout << -1;
  else
    cout << ans - 6;
  return 0;
}
