#include using namespace std; using ll = long long; using P = pair; using T = tuple; #define al(a) a.begin(), a.end() #define ral(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl; int main() { int n, m; cin >> n >> m; vector g(n, vector(n)); rep(i, m) { int a, b, c; cin >> a >> b >> c; g[a][b] = c; } vector p(n); iota(al(p), 0); int ans = 0; do { int now = 0; rep(i, n) rep(j, i) { now += g[p[j]][p[i]]; } ans = max(ans, now); } while (next_permutation(al(p))); cout << ans << endl; } // int main() { // int n, m; // cin >> n >> m; // vector t(m); // for (auto &[a, b, c] : t) { cin >> a >> b >> c; } // vector p(n); // iota(al(p), 0); // int ans = 0; // do { // int now = 0; // for (auto [a, b, c] : t) { // int na = 0, nb = 0; // rep(i, n) { // if (p[i] == a) na = i; // if (p[i] == b) nb = i; // } // if (na < nb) now += c; // } // ans = max(ans, now); // } while (next_permutation(al(p))); // cout << ans << endl; // return 0; // }