#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) {
    cerr << printArray[i] << between;
  }
  if (between != '\n') {
    cerr << endl;
  }
}
const int INF = 1e8;
int N, M;
int a[111], b[111], c[111];
int G[111][111];
void print() {
  for (int(i) = (0); (i) < (N); ++(i)) {
    for (int(j) = (0); (j) < (N); ++(j)) {
      if (G[i][j] == INF) {
        printf("%3c ", 'I');
      } else {
        printf("%3d ", G[i][j]);
      }
    }
    puts("");
  }
}
int main() {
  cin >> N >> M;
  for (int(i) = (0); (i) < (N); ++(i)) {
    for (int(j) = (0); (j) < (N); ++(j)) {
      if (i == j) continue;
      G[i][j] = G[j][i] = INF;
    }
  }
  for (int(i) = (0); (i) < (M); ++(i)) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    G[a[i]][b[i]] = G[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)) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int ans = M;
  for (int(i) = (0); (i) < (M); ++(i)) {
    bool shortest = false;
    for (int(j) = (0); (j) < (N); ++(j)) {
      if (G[j][a[i]] + c[i] == G[j][b[i]]) shortest = true;
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
  return 0;
}
