#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T x, T y) {
  if (!y) return x;
  return gcd(y, x % y);
}
template <class T>
inline T mod(T x) {
  if (x < 0)
    return -x;
  else
    return x;
}
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e2 + 5;
vector<pair<int, int> > adj[MAX];
int A[MAX][MAX];
int dist[MAX];
int par[MAX];
void dijstra(int x) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  int y, z, to, dis;
  pair<int, int> p;
  pq.push(make_pair(0, x));
  dist[x] = 0;
  while (!pq.empty()) {
    p = pq.top();
    pq.pop();
    y = p.second;
    z = p.first;
    for (__typeof(0) i = 0; i < adj[y].size(); i += 1) {
      to = adj[y][i].first;
      dis = adj[y][i].second;
      if (dis + z < dist[to]) {
        dist[to] = dis + y;
        par[to] = y;
        pq.push(make_pair(dist[to], to));
      }
    }
  }
}
int main(int argc, char* argv[]) {
  if (argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
  if (argc == 3) freopen(argv[2], "w", stdout);
  ios::sync_with_stdio(false);
  int n, m, x, y, c;
  cin >> n >> m;
  for (__typeof(0) i = 0; i < MAX; i += 1)
    for (__typeof(0) j = 0; j < MAX; j += 1) A[i][j] = -1;
  for (__typeof(0) i = 0; i < m; i += 1) {
    cin >> x >> y >> c;
    adj[x].push_back(make_pair(y, c));
    adj[y].push_back(make_pair(x, c));
    A[x][y] = c;
    A[y][x] = c;
  }
  for (__typeof(1) i = 1; i < n + 1; i += 1) {
    for (__typeof(1) j = 1; j < n + 1; j += 1) dist[j] = INF;
    dijstra(i);
    for (__typeof(1) j = 1; j < n + 1; j += 1) {
      A[par[j]][j] = 0;
      A[j][par[j]] = 0;
    }
  }
  int ans = 0;
  for (__typeof(1) i = 1; i < n + 1; i += 1) {
    for (__typeof(1) j = 1; j < n + 1; j += 1) {
      if (A[i][j] > 0) ans++;
    }
  }
  cout << (ans / 2) << endl;
  return 0;
}
