#include <bits/stdc++.h>
using namespace std;
int n = 0;
int m = 0;
int a = 0;
int b = 0;
int result = INT_MAX;
vector<int> degree;
vector<vector<bool>> g;
int main() {
  cin >> n >> m;
  degree.resize(n, 0);
  g.resize(n, vector<bool>(n, false));
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a][b] = true;
    g[b][a] = true;
    degree[a]++;
    degree[b]++;
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (g[i][j])
        for (int k = j + 1; k < n; k++)
          if (g[j][k] && g[i][k])
            result = min(result, degree[i] + degree[j] + degree[k]);
  if (result == INT_MAX)
    cout << "-1" << endl;
  else
    cout << result - 6;
  return 0;
}
