#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 102;
int d[MAX_V][MAX_V];
int ans[MAX_V][MAX_V];
const int INF = 1e8;
void setCost(int d[MAX_V][MAX_V], int s, int e, int cost) {
  d[s][e] = d[e][s] = cost;
}
int main() {
  int V, M;
  cin >> V >> M;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
      ans[i][j] = 0;
    }
  }
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b >> c;
    setCost(d, a - 1, b - 1, c - 1);
  }
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          ans[i][k]++;
          ans[k][j]++;
          if (ans[i][j] > 0) ans[i][j]--;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int count = 0;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (ans[i][j] == 0 && i != j) {
        count++;
      }
    }
  }
  cout << count / 2 << endl;
  return 0;
}
