#include <bits/stdc++.h>
using namespace std;
int f[100005], n, m, cost[100005], value[100005], num[100005], cnt;
bool vst[100005];
vector<int> e[100005];
const int inf = (1 << 28);
bool ck(int i) {
  while (i) {
    int j = i % 10;
    i /= 10;
    if (j != 4 && j != 7) return false;
  }
  return true;
}
void dfs(int i) {
  vst[i] = true;
  cnt++;
  for (vector<int>::iterator it = e[i].begin(); it != e[i].end(); it++) {
    if (vst[*it]) continue;
    dfs(*it);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int i, j;
    scanf("%d%d", &i, &j);
    e[i].push_back(j);
    e[j].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (vst[i]) continue;
    cnt = 0;
    dfs(i);
    num[cnt]++;
  }
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (num[i] == 0) continue;
    int j = 1;
    while (num[i] > j) {
      value[cnt] = i * j;
      cost[cnt++] = j;
      num[i] -= j;
      j <<= 1;
    }
    if (num[i]) {
      value[cnt] = num[i] * i;
      cost[cnt++] = num[i];
    }
  }
  for (int i = 1; i <= n; i++) f[i] = inf;
  for (int i = 0; i < cnt; i++)
    for (int j = n; j >= value[i]; j--)
      f[j] = min(f[j], f[j - value[i]] + cost[i]);
  int ans = inf;
  for (int i = 1; i <= n; i++)
    if (ck(i)) ans = min(ans, f[i]);
  if (ans == inf)
    printf("-1\n");
  else
    printf("%d\n", ans - 1);
  return 0;
}
