#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
int recog[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i, j, k, x, y, z, a, b, c;
  cin >> n >> m;
  for (i = 1; i <= m; ++i) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    recog[x]++;
    recog[y]++;
  }
  int ans = 1000000007;
  for (i = 1; i <= n; ++i) sort(v[i].begin(), v[i].end());
  for (i = 1; i <= n; ++i) {
    if (v[i].size() < 2) continue;
    for (j = 0; j < v[i].size(); ++j) {
      y = v[i][j];
      if (v[y].size() < 2) continue;
      for (k = 0; k < v[y].size(); ++k) {
        z = v[y][k];
        if (binary_search(v[z].begin(), v[z].end(), i))
          ans = min(ans, recog[i] + recog[y] + recog[z] - 6);
      }
    }
  }
  if (ans == 1000000007) ans = -1;
  cout << ans << endl;
  return 0;
}
