#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7,
          around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
const long long LINF = 1e18;
const long double PI = abs(acos(-1));
long long n, m, li[110][110], a[110], b[110], c[110];
int main() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++) li[i][j] = li[j][i] = LINF;
  for (int i = (0); i < (n); i++) li[i][i] = 0;
  for (int i = (0); i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    li[a[i]][b[i]] = li[b[i]][a[i]] = c[i];
  }
  for (int k = (0); k < (n); k++)
    for (int i = (0); i < (n); i++)
      for (int j = (0); j < (n); j++)
        li[i][j] = min(li[i][j], li[i][k] + li[k][j]);
  int cou = 0;
  for (int i = (0); i < (m); i++) {
    bool f = true;
    for (int j = (0); j < (n); j++) {
      for (int k = (0); k < (n); k++) {
        if (li[j][k] == li[j][a[i]] + c[i] + li[b[i]][k]) f = false;
      }
    }
    if (f) cou++;
  }
  cout << cou << endl;
  return 0;
}
