#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 1 << 30;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> deg(N, 0);                           // 次数
    vector<vector<int>> cost(N, vector<int>(N, 0));  // 隣接行列
    for (int i = 0; i < M; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        --u, --v;
        cost[u][v] = cost[v][u] = f;
        ++deg[u], ++deg[v];
    }

    int ans = 0;
    for (int d = 2; d * (d - 1) / 2 <= M; ++d) {
        // 頂点数dのクリークを全列挙
        vector<int> vs;
        for (int v = 0; v < N; ++v) {
            if (deg[v] >= d - 1) vs.push_back(v);
        }

        int K = vs.size();
        if (K < d) continue;

        vector<bool> pat(K, false);
        for (int i = 0; i < d; ++i) pat[K - i - 1] = true;

        // 要素数dの部分集合をnext_permutationで全列挙
        do {
            int sum = 0;
            for (int i = 0; i < K; ++i) {
                if (!pat[i]) continue;

                int mi = INF;
                for (int j = 0; j < K; ++j) {
                    if (i == j || !pat[j]) continue;
                    mi = min(mi, cost[vs[i]][vs[j]]);
                }
                sum += mi;
            }
            ans = max(ans, sum);
        } while (next_permutation(pat.begin(), pat.end()));
    }

    cout << ans << endl;
    return 0;
}

