#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long long int, long long int>& a,
               const pair<long long int, long long int>& b) {
  return (a.second < b.second);
}
bool comp(pair<long long int, pair<long long int, long long int>> a,
          pair<long long int, pair<long long int, long long int>> b) {
  if (a.first < b.first)
    return 1;
  else if (a.first > b.first)
    return 0;
  else {
    return a.second.first < b.second.first;
  }
}
long long int mpow(long long int x, long long int y) {
  long long int ans = 1;
  while (y) {
    if (y % 2 != 0) ans = (ans % 998244353) * (x % 998244353) % 998244353;
    y /= 2;
    x = ((x % 998244353) * (x % 998244353)) % 998244353;
  }
  return ans;
}
void bfs(vector<long long int> v[], long long int visit[], long long int s,
         long long int ans[]) {
  deque<long long int> q;
  q.push_back(s);
  visit[s] = 1;
  while (!q.empty()) {
    long long int x = q.front();
    q.pop_front();
    for (auto i = v[x].begin(); i != v[x].end(); i++) {
      if (!visit[*i]) {
        q.push_back(*i);
        visit[*i] = 1;
      }
    }
  }
}
void buildtree(int* tree, int* arr, int start, int end, int treeNode) {
  if (start < end) {
    int mid = start + (end - start) / 2;
    buildtree(tree, arr, start, mid, 2 * treeNode);
    buildtree(tree, arr, mid + 1, end, 2 * treeNode + 1);
    tree[treeNode] = tree[2 * treeNode] + tree[2 * treeNode + 1];
  }
}
void update(int* tree, int* arr, int start, int end, int pos, int val,
            int treeNode) {
  if (start == end)
    tree[treeNode] = val;
  else {
    int mid = start + (end - start) / 2;
    if (pos <= mid)
      update(tree, arr, start, mid, pos, val, 2 * treeNode);
    else
      update(tree, arr, mid + 1, end, pos, val, 2 * treeNode + 1);
    tree[treeNode] = tree[2 * treeNode] + tree[2 * treeNode + 1];
  }
}
void dfs(vector<long long int> v[], long long int visit[], long long int s,
         long long int pred[], vector<long long int>* p) {
  visit[s] = 1;
  for (auto i = v[s].begin(); i != v[s].end(); i++) {
    if (!visit[*i]) {
      pred[*i] = s;
      dfs(v, visit, *i, pred, p);
    }
  }
}
vector<long long int> factor(long long int n) {
  vector<long long int> v;
  if (n % 2 == 0) {
    while (n % 2 == 0) {
      n /= 2;
      v.push_back(2);
    }
  }
  for (long long int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        v.push_back(i);
      }
    }
  }
  if (n > 1) v.push_back(n);
  return v;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, m, j;
  cin >> n >> m;
  long long int x[m], y[m];
  vector<long long int> v[n];
  long long int p[n][n];
  memset(p, 0, sizeof(p));
  for (i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
    p[x[i]][y[i]] = 1;
    p[y[i]][x[i]] = 1;
  }
  long long int ans = INT_MAX;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      if (p[x[i]][j] && p[y[i]][j])
        ans = min(ans, (long long int)(v[x[i]].size() + v[y[i]].size() +
                                       v[j].size() - 6));
    }
  }
  if (ans == INT_MAX)
    cout << "-1";
  else
    cout << ans;
  return 0;
}
