#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dist[100][100];
const int INF = pow(10, 9);
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= n - 1; j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = INF;
    }
  }
  for (int i = 0; i <= m - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  bool visited[n][n];
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= n - 1; j++) {
      visited[i][j] = false;
    }
  }
  for (int k = 0; k <= n - 1; k++) {
    for (int i = 0; i <= n - 1; i++) {
      for (int j = 0; j <= n - 1; j++) {
        if (i == j) continue;
        if (i == k) continue;
        if (j == k) continue;
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          visited[i][k] = true;
          visited[k][j] = true;
          dist[i][j] = dist[i][k] + dist[k][j];
        } else if (dist[i][j] < dist[i][k] + dist[k][j]) {
          visited[i][j] = true;
        } else {
          visited[i][k] = true;
          visited[k][j] = true;
          visited[i][j] = true;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= n - 1; j++) {
      if (i == j) continue;
      if (!visited[i][j]) {
        ++ans;
      }
    }
  }
  cout << ans / 2 << endl;
}
