#include <bits/stdc++.h>
using namespace std;
int n, m, f[110][110], ans;
struct edge {
  int to, ca;
};
vector<edge> map[110];
bool v[110], used[110][110];
bool exist[110][110];
struct node {
  int d[1010][2], sz, c;
};
void dfs(int a, int from, node x) {
  if (f[a][from] == x.c) {
    for (int i = 1; i <= x.sz; i++) used[x.d[i][0]][x.d[i][1]] = 1;
  }
  v[a] = 1;
  node x1 = x;
  for (int i = 0; i < map[a].size(); i++) {
    edge y = map[a][i];
    if (!v[y.to]) {
      x = x1;
      x.sz++;
      x.c += y.ca;
      x.d[x.sz][0] = a;
      x.d[x.sz][1] = y.to;
      dfs(y.to, from, x);
    }
  }
  v[a] = 0;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = 1 << 30;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    edge x;
    x.to = b;
    x.ca = c;
    map[a].push_back(x);
    x.to = a;
    map[b].push_back(x);
    f[a][b] = c;
    f[b][a] = c;
    exist[a][b] = 1;
    exist[b][a] = 1;
  }
  for (int i = 1; i <= n; i++) f[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j && f[i][k] + f[k][j] < f[i][j]) {
          f[i][j] = f[i][k] + f[k][j];
        }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) v[j] = 0;
    node x;
    x.sz = 0;
    x.c = 0;
    dfs(i, i, x);
  }
  ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (!used[i][j] && !used[j][i] && exist[i][j]) ans++;
  printf("%d\n", ans / 2);
  return 0;
}
