#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct node {
  int x, y, z;
};
int n, fa[N][19], d[N], f[N], tott, sum[N], sumv[N], L[N], R[N];
vector<int> g[N];
vector<node> v[N];
void add(int x, int v) {
  for (int i = x; i > 0 && i <= n; i += ((i) & (-i))) sumv[i] += v;
}
int ask(int x) {
  int ans = 0;
  for (int i = x; i > 0; i -= ((i) & (-i))) ans += sumv[i];
  return ans;
}
int LCA(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  for (int i = (18); i >= (0); i--)
    if (d[fa[x][i]] >= d[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = (18); i >= (0); i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void dfs(int x) {
  L[x] = ++tott;
  for (auto p : g[x]) {
    d[p] = d[x] + 1;
    dfs(p);
  }
  R[x] = tott;
}
void dfs2(int x) {
  sum[x] = 0;
  for (auto p : g[x]) dfs2(p), sum[x] += f[p];
  f[x] = sum[x];
  for (auto p : v[x]) {
    int tmp = ask(L[p.x]) + ask(L[p.y]) - 2 * ask(L[x]);
    tmp += sum[x];
    tmp += p.z;
    f[x] = max(f[x], tmp);
  }
  add(L[x], sum[x] - f[x]);
  add(R[x] + 1, f[x] - sum[x]);
}
int main() {
  int m;
  cin >> n >> m;
  for (int i = (2); i <= (n); i++)
    scanf("%d", &fa[i][0]), g[fa[i][0]].push_back(i);
  for (int j = (1); j <= (18); j++)
    for (int i = (1); i <= (n); i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
  int x, y, z;
  d[1] = 1;
  dfs(1);
  for (int i = (1); i <= (m); i++) {
    scanf("%d%d%d", &x, &y, &z);
    v[LCA(x, y)].push_back((node){x, y, z});
  }
  dfs2(1);
  cout << f[1] << endl;
  return 0;
}
