#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int N, m, a, b, c;
pair<int, int> M[MAX][MAX];
void dijkstra() {
  int minv;
  int d[MAX], color[MAX];
  for (int i = 0; i < N; i++) {
    d[i] = 1e+9;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while (1) {
    minv = 1e+9;
    int u = -1;
    for (int i = 0; i < N; i++) {
      if (minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    for (int v = 0; v < N; v++) {
      if (color[v] != BLACK && M[u][v].first != 1e+9) {
        if (d[v] > d[u] + M[u][v].first) {
          d[v] = d[u] + M[u][v].first;
          color[v] = GRAY;
          M[u][v].second = 2;
          M[v][u].second = 2;
        }
      }
    }
  }
}
int main() {
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++) {
      M[i][j].first = 1e+9;
      M[i][j].second = 0;
    }
  cin >> N >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    M[a - 1][b - 1].first = c;
    M[b - 1][a - 1].first = c;
    M[a - 1][b - 1].second = 1;
    M[b - 1][a - 1].second = 1;
  }
  dijkstra();
  long long ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = i; j < N; j++) {
      if (M[i][j].second == 1) ans++;
    }
  cout << ans << endl;
  return 0;
}
