#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graf;
vector<bool> used;
int main() {
  int n, m;
  cin >> n >> m;
  graf.resize(n);
  for (int i = 0; i < m; i++) {
    int k, l;
    cin >> k >> l;
    graf[k - 1].push_back(l - 1);
    graf[l - 1].push_back(k - 1);
  }
  int ans = 10000000;
  used.resize(n, false);
  for (int i = 0; i < n; i++) {
    used[i] = true;
    for (int j = 0; j < graf[i].size(); j++) {
      int i2 = graf[i][j];
      if (!used[i2] && i2 != i)
        for (int k = 0; k < graf[i2].size(); k++) {
          int i3 = graf[i2][k];
          if (!used[i3] && i3 != i2 && i3 != i)
            for (int m = 0; m < graf[i3].size(); m++) {
              if (graf[i3][m] == i)
                ans = min(ans, int(graf[i].size() - 2 + graf[i2].size() - 2 +
                                   graf[i3].size() - 2));
            }
        }
    }
  }
  cout << (ans == 10000000 ? -1 : ans);
  return 0;
}
