#include <bits/stdc++.h>
using namespace std;
long long s[1100][1100];
bool us[110][110] = {};
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) s[i][j] = 1999999999;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    s[a][b] = c;
    s[b][a] = c;
    us[a][b] = true;
    us[b][a] = true;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (k != i and k != j and s[i][j] >= s[i][k] + s[k][j]) {
          us[i][k] = false;
          us[k][j] = false;
        }
        s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (us[i][j]) ans++;
  cout << ans / 2 << endl;
}
