#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    --x;
    --y;
    a[x][y] = a[y][x] = z;
  }
  const int inf = (int)1e9;
  vector<int> dp(1 << n, inf);
  dp[1] = 0;
  for (int t = 0; t < (1 << n); t++) {
    if (dp[t] == inf) continue;
    int u = (1 << n) - 1 - t;
    while (u > 0) {
      int mx = 0;
      int sum = 0;
      for (int i = 0; i < n; i++) {
        if (t & (1 << i)) {
          for (int j = 0; j < n; j++) {
            if (u & (1 << j)) {
              sum += a[i][j];
              mx = max(mx, a[i][j]);
            }
          }
        }
      }
      dp[t | u] = min(dp[t | u], dp[t] + sum - mx);
      u = (u - 1) & t;
    }
  }
  cout << dp[(1 << n) - 1] << '\n';
  return 0;
}
