#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
vector<vector<long long int>> v;
long long int cnt = 0;
vector<long long int> dep;
bool visited[MAX];
vector<long long int> par;
long long int dfs(long long int s, long long int n) {
  stack<long long int> st;
  st.push(s);
  cout << s << endl;
  while (!st.empty()) {
    long long int u = st.top();
    st.pop();
    if (!visited[u]) {
      visited[u] = true;
      cout << u << " !! ";
    }
    for (auto it : v[u]) {
      if (!visited[it]) {
        st.push(it);
        par[it] = u;
      } else if (par[par[u]] == it) {
        cnt = v[it].size() + v[u].size() + v[par[u]].size();
        return cnt;
      }
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n, m;
  cin >> n >> m;
  long long int x, y;
  long long int mat[n][n];
  memset(mat, 0, sizeof(mat));
  long long int size[n];
  memset(size, 0, sizeof(size));
  for (long long int(i) = 0; i < (m); i++) {
    cin >> x >> y;
    x--;
    y--;
    mat[x][y] = 1;
    mat[y][x] = 1;
    size[x]++;
    size[y]++;
  }
  long long int mn = INT_MAX;
  for (long long int i = 0; i < n; i++) {
    if (size[i] < 2) continue;
    for (long long int j = i + 1; j < n - 1; j++) {
      if (mat[i][j]) {
        if (size[j] > 1) {
          for (long long int k = j + 1; k < n; k++) {
            if (mat[j][k] && mat[i][k]) {
              mn = min(mn, size[i] + size[j] + size[k]);
            }
          }
        }
      }
    }
  }
  if (mn == INT_MAX)
    cout << -1 << endl;
  else
    cout << mn - 6 << endl;
  return 0;
}
