#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0)
    return c;
  else
    return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E12;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long* pos, long long val) { *pos = max(*pos, val); }
void Min(long long* pos, long long val) { *pos = min(*pos, val); }
void Add(long long* pos, long long val) { *pos = mod(*pos + val); }
const long double EPS = 1E-8;
long long n, m;
vector<pair<long long, long long> > v[105];
struct edge {
  long long a, b, c;
};
vector<edge> e;
int main() {
  cin >> n >> m;
  for (long long i = 0; i <= m - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[a].push_back(pair<long long, long long>(b, c));
    v[b].push_back(pair<long long, long long>(a, c));
    edge ed;
    ed.a = a;
    ed.b = b;
    ed.c = c;
    e.push_back(ed);
  }
  long long ans = 0;
  long long dp[n][n];
  for (long long i = 0; i <= n - 1; i++)
    for (long long j = 0; j <= n - 1; j++) dp[i][j] = inf;
  for (long long i = 0; i <= n - 1; i++) dp[i][i] = 0;
  for (auto x : e) {
    long long a = x.a, b = x.b, c = x.b;
    for (long long i = 0; i <= n - 1; i++) {
      dp[a][b] = c;
      dp[b][a] = c;
    }
  }
  for (long long k = 0; k <= n - 1; k++) {
    for (long long i = 0; i <= k; i++) {
      for (long long j = 0; j <= k; j++) {
        Min(&dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  for (auto x : e) {
    if (dp[x.a][x.b] < x.c) ans++;
  }
  cout << ans << endl;
  return 0;
}
