#include <bits/stdc++.h>
using namespace std;
struct FastIO {
  static const int S = 1310720;
  int wpos;
  char wbuf[S];
  FastIO() : wpos(0) {}
  inline int xchar() {
    static char buf[S];
    static int len = 0, pos = 0;
    if (pos == len) pos = 0, len = fread(buf, 1, S, stdin);
    if (pos == len) return -1;
    return buf[pos++];
  }
  inline int xuint() {
    int c = xchar(), x = 0;
    while (c <= 32) c = xchar();
    for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
    return x;
  }
  inline int xint(int& in) {
    int s = 1, c = xchar(), x = 0;
    while (c <= 32) {
      c = xchar();
      if (c == -1) {
        return 0;
      }
    }
    if (c == '-') s = -1, c = xchar();
    for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
    int res = x * s;
    in = res;
    return 1;
  }
  inline void xstring(char* s) {
    int c = xchar();
    while (c <= 32) c = xchar();
    for (; c > 32; c = xchar()) *s++ = c;
    *s = 0;
  }
  inline void wchar(int x) {
    if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
    wbuf[wpos++] = x;
  }
  inline void wint(int x) {
    if (x < 0) wchar('-'), x = -x;
    char s[24];
    int n = 0;
    while (x || !n) s[n++] = '0' + x % 10, x /= 10;
    while (n--) wchar(s[n]);
  }
  inline void wstring(const char* s) {
    while (*s) wchar(*s++);
  }
  ~FastIO() {
    if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
  }
} io;
int n, m, tot;
struct E {
  int a;
  int nxt;
};
struct TR {
  int x, y, z;
};
int g[100013 * 2];
E e[100013 * 2 << 1];
TR q[100013 * 2];
int ace[100013 * 2][19];
void addE(int x, int y) {
  ++tot;
  e[tot].a = y;
  e[tot].nxt = g[x];
  g[x] = tot;
}
int siz[100013 * 2], top[100013 * 2], fa[100013 * 2], son[100013 * 2],
    deep[100013 * 2], tid[100013 * 2];
void dfs1(int v, int p, int d) {
  siz[v] = 1;
  deep[v] = d;
  fa[v] = p;
  son[v] = -1;
  for (int i = g[v]; i != -1; i = e[i].nxt) {
    int w = e[i].a;
    if (w == p) {
      continue;
    }
    dfs1(w, v, d + 1);
    siz[v] += siz[w];
    if (son[v] == -1 || siz[w] > siz[son[v]]) {
      son[v] = w;
    }
  }
  return;
}
long long tr[1000013 * 2];
void ins(int d, int l, int r, int x, int c) {
  if (l > r || x < l || x > r) return;
  if (l == r) {
    tr[d] = c;
    return;
  }
  int o = l + r >> 1, ll = d << 1, rr = ll + 1;
  if (x <= o)
    ins(ll, l, o, x, c);
  else
    ins(rr, o + 1, r, x, c);
  tr[d] = tr[ll] + tr[rr];
}
long long query(int d, int l, int r, int x, int y) {
  if (l > r || x > y || x < l || y > r) return 0;
  if (l == x && y == r) {
    return tr[d];
  }
  int o = l + r >> 1, ll = d << 1, rr = ll + 1;
  long long res = 0;
  if (y <= o)
    res = query(ll, l, o, x, y);
  else if (x > o)
    res = query(rr, o + 1, r, x, y);
  else
    res = query(ll, l, o, x, o) + query(rr, o + 1, r, o + 1, y);
  return res;
}
std::vector<int> v[100013 * 2];
void dfs2(int v, int tp, int& k) {
  top[v] = tp;
  tid[v] = ++k;
  if (son[v] == -1) {
    return;
  }
  dfs2(son[v], tp, k);
  for (int i = g[v]; i != -1; i = e[i].nxt) {
    int w = e[i].a;
    if (w == fa[v] || w == son[v]) {
      continue;
    }
    dfs2(w, w, k);
  }
}
long long ans[100013 * 2], sans[100013 * 2];
long long fts(int u, int v) {
  long long ans = 0;
  while (top[u] != top[v]) {
    if (deep[top[u]] > deep[top[v]]) {
      ans += query(1, 1, n, tid[top[u]], tid[u]);
      u = fa[top[u]];
    } else {
      ans += query(1, 1, n, tid[top[v]], tid[v]);
      v = fa[top[v]];
    }
  }
  if (deep[u] < deep[v]) {
    ans += query(1, 1, n, tid[u], tid[v]);
  } else {
    ans += query(1, 1, n, tid[v], tid[u]);
  }
  return ans;
}
void dfs(int x) {
  sans[x] = 0;
  for (int p = g[x]; p != -1; p = e[p].nxt) {
    int y = e[p].a;
    if (y != fa[x]) {
      dfs(y);
      sans[x] += ans[y];
    }
  }
  ans[x] = sans[x];
  for (int i = 0; i < v[x].size(); ++i) {
    TR k = q[v[x][i]];
    long long tmp;
    tmp = fts(x, k.x) + fts(x, k.y) + sans[x] + k.z;
    ans[x] = max(ans[x], tmp);
  }
  ins(1, 1, n, tid[x], sans[x] - ans[x]);
}
int acen(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  int j = 18;
  while (deep[x] != deep[y]) {
    if (ace[x][j] != 0) {
      if (deep[ace[x][j]] >= deep[y]) x = ace[x][j];
    }
    --j;
  }
  if (x == y) return x;
  j = 18;
  int l = deep[x], r = 0, ac = 1;
  while (r + 1 < l) {
    int a = ace[x][j];
    int b = ace[y][j];
    if (a == b) {
      if (a != 0 && deep[a] > r) r = deep[a], ac = a;
    } else {
      x = ace[x][j];
      y = ace[y][j];
      l = deep[x];
    }
    --j;
  }
  return ac;
}
int main() {
  int T = 1;
  for (int ci = 1; ci <= T; ++ci) {
    scanf("%d%d", &n, &m);
    tot = -1;
    memset(g, -1, sizeof(g));
    for (int i = 2; i <= n; ++i) {
      int x;
      scanf("%d", &x);
      addE(i, x);
      addE(x, i);
    }
    dfs1(1, 0, 0);
    int k = 0;
    dfs2(1, 1, k);
    for (int i = 0; i < 19; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (i == 0)
          ace[j][i] = fa[j];
        else {
          int t = ace[j][i - 1];
          if (t == 0)
            ace[j][i] = 0;
          else
            ace[j][i] = ace[t][i - 1];
        }
      }
    }
    for (int i = 1; i <= n; ++i) v[i].clear();
    for (int i = 0; i < m; ++i) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      q[i].x = x;
      q[i].y = y;
      q[i].z = z;
      int aa = acen(x, y);
      v[aa].push_back(i);
    }
    memset(tr, 0, sizeof(tr));
    dfs(1);
    cout << ans[1] << endl;
  }
  return 0;
}
