#include <bits/stdc++.h>
using namespace std;
long long int M = 1000000000 + 7;
long long int power(long long int x, long long int n) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
bool mp[4005][4005] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v[n + 1];
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    mp[a][b] = 1;
    mp[b][a] = 1;
  }
  long long int ans = INT_MAX;
  for (long long int i = 1; i <= n; i++) {
    vector<long long int>& nv = v[i];
    long long int siz = nv.size();
    for (long long int j = 0; j < siz; j++) {
      for (long long int k = j + 1; k < siz; k++) {
        long long int x = nv[j], y = nv[k];
        if (mp[x][y] == 1) {
          long long int cursum = v[i].size() + v[x].size() + v[y].size();
          ans = min(ans, cursum);
        }
      }
    }
  }
  if (ans == INT_MAX) ans = 5;
  cout << ans - 6 << endl;
}
