#include <bits/stdc++.h>
using namespace std;
int N, M;
int D[105][105];
bool C[1010];
int DD[1010];
map<pair<int, int>, int> MM;
bool done[105][105];
void dfs(int from, int to) {
  if (done[from][to]) return;
  done[from][to] = true;
  for (int i = 0; i < N; i++)
    if (i != from && i != to) {
      if (D[from][i] + D[i][to] == D[from][to]) {
        C[MM[make_pair(from, i)]] = true;
        C[MM[make_pair(i, to)]] = true;
        dfs(i, to);
      }
    }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) D[i][j] = INT_MAX / 2;
  for (int i = 0; i < N; i++) D[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    D[a][b] = D[b][a] = c;
    MM[make_pair(a, b)] = i + 1;
    MM[make_pair(b, a)] = i + 1;
    DD[i + 1] = c;
  }
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++) {
      if (0 < MM[make_pair(i, j)]) {
        if (D[i][j] == DD[MM[make_pair(i, j)]]) {
          C[MM[make_pair(i, j)]] = true;
        }
      }
      dfs(i, j);
    }
  int ans = 0;
  for (int i = 1; i < M + 1; i++)
    if (!C[i]) {
      ans++;
    }
  cout << ans << endl;
}
