#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long x, y;
  vector<vector<long long>> graph(n + 1, vector<long long>());
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  vector<long long> f(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    f[i] = graph[i].size();
    sort(graph[i].begin(), graph[i].end());
  }
  long long ans = INT_MAX;
  for (int i = 1; i <= n; i++) {
    if (f[i] >= 2) {
      for (int j = 0; j < f[i] - 1; j++) {
        for (int k = j + 1; k < f[i]; k++) {
          if (binary_search(graph[graph[i][j]].begin(),
                            graph[graph[i][j]].end(), graph[i][k])) {
            ans = min(ans, f[i] + f[graph[i][j]] + f[graph[i][k]] - 6);
          }
        }
      }
    }
  }
  if (ans == INT_MAX) ans = -1;
  cout << ans;
}
