#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using ld = long double;
using V = vector<int>;
using Vl = vector<ll>;
using VV = vector<vector<int>>;
using VVl = vector<vector<ll>>;
int main() {
  int n, m;
  cin >> n >> m;
  VVl d(n, Vl(n, INF));
  VVl copy(n, Vl(n, INF));
  VV ch(n, V(n, 0));
  for (int i = 0; i < n; ++i) {
    d[i][i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    copy[a][b] = c;
    copy[b][a] = c;
    ch[a][b] = 1;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int sub = 0;
  for (int s = 0; s < n; ++s) {
    for (int g = 0; g < n; ++g) {
      int cur = s;
      while (cur != g) {
        for (int i = 0; i < n; ++i) {
          if (i != cur and copy[cur][i] + d[i][g] == d[cur][g]) {
            if (ch[cur][i]) {
              sub++;
              ch[cur][i] = 0;
            }
            if (ch[i][cur]) {
              sub++;
              ch[i][cur] = 0;
            }
            cur = i;
            break;
          }
        }
      }
    }
  }
  cout << m - sub << endl;
}
