#include <bits/stdc++.h>
using namespace std;

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n));
  int sum_w = 0;
  while (m--) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    g[u][v] = g[v][u] = w;
    sum_w += w;
  }
  vector<int> sum(1 << n);
  for (int bt = 1; bt < 1 << n; ++bt) {
    int v = __builtin_ctz(bt);
    sum[bt] = sum[bt ^ 1 << v];
    for (int u = 0; u < n; ++u) {
      if (bt >> u & 1) {
        sum[bt] += g[v][u];
      }
    }
  }
  vector<vector<int>> dp(n, vector<int>(1 << n, -inf));
  for (int bt = 1; bt < 1 << n; bt += 2) {
    dp[0][bt] = sum[bt];
  }
  for (int bt = 0; bt < 1 << n; ++bt) {
    for (int v = 0; v < n; ++v) {
      if (dp[v][bt] == -inf) {
        continue;
      }
      int cbt = bt ^ ~-(1 << n);
      for (int nxt = cbt; nxt; nxt = (nxt - 1) & cbt) {
        for (int nv = 0; nv < n; ++nv) {
          if (nxt >> nv & 1 and g[v][nv]) {
            dp[nv][bt | nxt] = max(dp[nv][bt | nxt], dp[v][bt] + g[v][nv] + sum[nxt]);
          }
        }
      }
    }
  }
  int res = sum_w - dp.back().back();
  cout << res << '\n';
}
