#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 101, INF = 999999;
static int cost[MAX_V][MAX_V];
static int edge[MAX_V][MAX_V];
static int d[MAX_V];
static int pre[MAX_V];
bool used[MAX_V];
static int V, E;
void input() {
  memset(cost, INF, sizeof(cost));
  cin >> E >> V;
  for (int i = 0; i < V; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    cost[a - 1][b - 1] = w;
    cost[b - 1][a - 1] = w;
    edge[a - 1][b - 1] = 1;
    edge[b - 1][a - 1] = 1;
  }
}
void dijkstra(int s) {
  fill(d, d + V, INF);
  fill(used, used + V, false);
  fill(pre, pre + V, -1);
  d[s] = 0;
  while (true) {
    int v = -1;
    for (int u = 0; u < V; u++) {
      if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;
    for (int u = 0; u < V; u++) {
      if (d[u] > d[v] + cost[v][u]) {
        d[u] = d[v] + cost[v][u];
        pre[u] = v;
      }
    }
  }
}
void get_path(int t) {
  for (; t != -1; t = pre[t]) {
    if (pre[t] == -1) return;
    if (pre[t] < 0 || pre[t] > V) return;
    edge[t][pre[t]]--;
    edge[pre[t]][t]--;
  }
}
int main() {
  input();
  for (int i = 0; i < V - 1; i++) {
    dijkstra(i);
    for (int j = i + 1; j < V; j++) {
      get_path(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      if (edge[i][j] == 1) ans++;
    }
  }
  cout << (int)ans / 2 << endl;
  return 0;
}
