#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, n, m, ans = 100000000;
int arr[4005][4005];
int mo[40005];
vector<int> gr[4005];
int dfs(int x) {
  mo[x]++;
  for (int i = 0; i < gr[x].size(); i++) {
    a = gr[x][i];
    for (int l = 0; l < gr[a].size(); l++) {
      b = gr[a][l];
      if (arr[x][b] == 1) {
        c = gr[x].size() + gr[a].size() + gr[b].size() - 6;
        ans = min(ans, c);
      }
    }
  }
  for (int i = 0; i < gr[x].size(); i++) {
    a = gr[x][i];
    if (mo[a] == 0) {
      dfs(a);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    gr[a].push_back(b);
    gr[b].push_back(a);
    arr[a][b] = 1;
    arr[b][a] = 1;
  }
  for (int i = 1; i <= n + 1; i++) {
    if (gr[i].size() >= 1 && mo[i] == 0) {
      dfs(i);
    }
  }
  if (ans == 100000000) {
    cout << -1;
  } else {
    cout << ans;
  }
}
