#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int lucky[65] = {0,     4,     7,     44,    47,    74,    77,    444,   447,
                 474,   477,   744,   747,   774,   777,   4444,  4447,  4474,
                 4477,  4744,  4747,  4774,  4777,  7444,  7447,  7474,  7477,
                 7744,  7747,  7774,  7777,  44444, 44447, 44474, 44477, 44744,
                 44747, 44774, 44777, 47444, 47447, 47474, 47477, 47744, 47747,
                 47774, 47777, 74444, 74447, 74474, 74477, 74744, 74747, 74774,
                 74777, 77444, 77447, 77474, 77477, 77744, 77747, 77774, 77777};
int f[MAXN];
bool lk[MAXN];
map<int, int> mp;
struct edge {
  int v;
  edge *nxt;
  edge() {
    v = 0;
    nxt = NULL;
  }
} * head[MAXN];
void adde(int u, int v) {
  edge *p = new edge;
  p->v = v;
  p->nxt = head[u];
  head[u] = p;
}
int col[MAXN];
int sz[MAXN], tot = 0;
void dfs(int u) {
  col[u] = tot;
  sz[tot]++;
  for (edge *i = head[u]; i != NULL; i = i->nxt) {
    int v = i->v;
    if (col[v]) continue;
    dfs(v);
  }
}
bool cmp(const int &l, const int &r) { return l > r; }
int main() {
  for (int i = 1; i <= 62; i++) lk[lucky[i]] = 1;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adde(u, v);
    adde(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!col[i]) {
      tot++;
      dfs(i);
    }
  for (int i = 1; i <= tot; i++) mp[sz[i]]++;
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    int c = it->first, k = it->second;
    while (k) {
      int _k = (k + 1) >> 1;
      for (int i = n; i >= c * _k; i--) f[i] = min(f[i], f[i - c * _k] + _k);
      k >>= 1;
    }
  }
  int ans = f[100005];
  for (int i = 0; i <= n; i++)
    if (lk[i]) ans = min(ans, f[i]);
  if (ans == f[100005])
    puts("-1");
  else
    printf("%d\n", ans - 1);
  return 0;
}
