#include <bits/stdc++.h>
using namespace std;
int r = 0, c = 0, xd = 0, yd = 0;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int flag = 0;
int n = 0, m = 0;
vector<int> v[4005];
int visited[4005];
int pr[4005];
int ans = 1000000007;
int con[4005][4005];
void dfs(int root) {
  visited[root] = 1;
  for (int i = 0; i < v[root].size(); i++) {
    int ele = v[root][i];
    if (!visited[ele]) {
      pr[ele] = root;
      dfs(ele);
    } else {
      cout << "ELE: " << ele << endl;
      int pr_root = pr[root];
      while (pr_root != -1) {
        if (con[pr_root][root] == 1 && con[pr_root][ele] == 1) {
          int sz1 = v[root].size();
          int sz2 = v[ele].size();
          int sz3 = v[pr_root].size();
          int h = sz1 + sz2 + sz3 - 6;
          cout << "H: " << h << endl;
          ans = min(ans, h);
          break;
        }
        pr_root = pr[pr_root];
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  vector<pair<int, int> > y;
  for (int i = 1; i <= m; i++) {
    int t1;
    int t2;
    scanf("%d %d", &t1, &t2);
    y.push_back(make_pair(t1, t2));
    v[t1].push_back(t2);
    v[t2].push_back(t1);
    con[t1][t2] = 1;
    con[t2][t1] = 1;
  }
  for (int i = 0; i < y.size(); i++) {
    int e1 = y[i].first;
    int e2 = y[i].second;
    for (int e3 = 1; e3 <= n; e3++) {
      if (e3 != e2 && e3 != e1 && con[e1][e3] == 1 && con[e2][e3] == 1) {
        int s1 = v[e1].size();
        int s2 = v[e2].size();
        int s3 = v[e3].size();
        ans = min(ans, s1 + s2 + s3 - 6);
      }
    }
  }
  if (ans == 1000000007) ans = -1;
  printf("%d\n", ans);
  return 0;
}
