#include <bits/stdc++.h>
using namespace std;
int n, m;
int par[100010], sz[100010], c[100010], dp[100010];
bool isLucky(int x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
int find(int x) { return (par[x] == x) ? x : par[x] = find(par[x]); }
void upd(int val, int wt) {
  for (int i = n; i >= val; i--) dp[i] = min(dp[i], dp[i - val] + wt);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) par[i] = i, sz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    int U = find(u), V = find(v);
    if (U != V) {
      if (sz[U] <= sz[V])
        sz[V] += sz[U], sz[U] = 0, par[U] = V;
      else
        sz[U] += sz[V], sz[V] = 0, par[V] = U;
    }
  }
  for (int i = 1; i <= n; i++) c[sz[i]]++, dp[i] = 1e9;
  for (int i = 1; i <= n; i++)
    if (c[i]) {
      for (int j = 1; j <= c[i]; j <<= 1) upd(j * i, j), c[i] -= j;
      upd(c[i] * i, c[i]);
    }
  int res = 1e9;
  for (int i = 1; i <= n; i++)
    if (isLucky(i)) res = min(res, dp[i]);
  printf("%d\n", res == 1e9 ? -1 : res - 1);
  return 0;
}
