#include <bits/stdc++.h>
using namespace std;
int br, edges;
vector<int> graph[100005];
map<int, int> comp;
bool u[100005];
queue<int> q;
int dp[100005];
const int INF = (1 << 30);
int bfs(int start) {
  int result = 0;
  q.push(start);
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    if (u[top]) continue;
    ++result;
    u[top] = true;
    for (int i = 0; i < graph[top].size(); ++i) {
      int att = graph[top][i];
      if (u[att]) continue;
      q.push(att);
    }
  }
  return result;
}
inline void calculate() {
  for (int i = 1; i <= br; ++i) {
    if (!u[i]) {
      int result = bfs(i);
      comp[result]++;
    }
  }
}
void variations(int value, int counter) {
  int remainder = counter, power = 1;
  while (true) {
    for (int z = br - power * value; z >= 0; --z) {
      if (dp[z] == -1) continue;
      if (dp[z + power * value] == -1)
        dp[z + power * value] = dp[z] + power;
      else
        dp[z + power * value] = min(dp[z + power * value], dp[z] + power);
    }
    remainder -= power;
    power *= 2;
    if (power > remainder) {
      power = remainder;
    }
    if (remainder == 0) break;
  }
}
inline void knapsack() {
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for (auto iter = comp.begin(); iter != comp.end(); ++iter) {
    int value, counter;
    tie(value, counter) = *iter;
    variations(value, counter);
  }
}
bool lucky(int number) {
  while (number > 0) {
    int rem = number % 10;
    number /= 10;
    if (rem != 4 && rem != 7) return false;
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> br >> edges;
  for (int i = 0; i < edges; ++i) {
    int from, to;
    cin >> from >> to;
    graph[from].push_back(to);
    graph[to].push_back(from);
  }
  calculate();
  knapsack();
  int minimum = INF;
  for (int i = 1; i <= br; ++i) {
    if (lucky(i) && dp[i] != -1) {
      minimum = min(minimum, dp[i]);
    }
  }
  if (minimum == INF) {
    cout << -1 << '\n';
    return 0;
  }
  cout << minimum - 1 << '\n';
  return 0;
}
