#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e4;
int n, m, cn[maxN];
vector<int> a[maxN];
bool mark;
int mn = 1e5;
bool know(int v, int z) {
  for (int i = 0; i < a[v].size(); i++)
    if (a[v][i] == z) return true;
  return false;
}
void coun(int v, int x, int z) {
  int su = 0;
  fill(cn, cn + n + 100, 0);
  for (int i = 0; i < a[v].size(); i++) cn[a[v][i]]++;
  for (int i = 0; i < a[x].size(); i++) cn[a[x][i]]++;
  for (int i = 0; i < a[z].size(); i++) cn[a[z][i]]++;
  cn[v] = 0;
  cn[x] = 0;
  cn[z] = 0;
  for (int i = 1; i <= n; i++) su += cn[i];
  mn = min(su, mn);
}
int main() {
  cin >> n >> m;
  int x, y;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < a[i].size(); j++)
      for (int k = 1; k <= n; k++) {
        if (i != k && a[i][j] != k && a[i][j] != i) {
          if (know(k, a[i][j]) && know(k, i)) {
            mark = true;
            coun(i, a[i][j], k);
          }
        }
      }
  if (!mark)
    cout << -1;
  else
    cout << mn;
  return 0;
}
