#include <bits/stdc++.h>
using namespace std;
const long long inf = 100000005;
bool a[5001][5001];
long long degree[5001];
unordered_map<long long, long long> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long d, e;
    cin >> d >> e;
    a[d][e] = a[e][d] = true;
    degree[d]++;
    degree[e]++;
  }
  long long res = inf;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      if (a[i][j]) {
        for (long long k = j + 1; k <= n; k++) {
          if (a[i][k] && a[j][k]) {
            res = min(res, degree[i] + degree[j] + degree[k]);
          }
        }
      }
    }
  }
  if (res == inf)
    cout << "-1";
  else
    cout << res - 6;
  return 0;
}
