#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next, v, c;
} e[810000];
const long long INF = (1LL) << 60;
int head[110000], dc[110000];
long long d[110000];
bool v[110000];
int n, m, o, kk;
void add(int x, int y, int z, int cost) {
  e[o].to = y;
  e[o].v = z;
  e[o].next = head[x];
  e[o].c = cost;
  head[x] = o++;
}
bool spfa(int s) {
  for (int i = 1; i <= n; i++) d[i] = INF;
  memset(dc, 0x3f, sizeof(dc));
  memset(v, 0, sizeof(v));
  v[s] = 1;
  d[s] = 0;
  dc[s] = 0;
  deque<int> q;
  q.push_back(s);
  while (!q.empty()) {
    int now = q.front();
    q.pop_front();
    for (int k = head[now]; k != -1; k = e[k].next)
      if (d[e[k].to] > d[now] + e[k].v ||
          (d[e[k].to] == d[now] + e[k].v && dc[e[k].to] > e[k].c)) {
        d[e[k].to] = d[now] + e[k].v;
        dc[e[k].to] = e[k].c;
        if (!v[e[k].to]) {
          v[e[k].to] = 1;
          if (q.empty())
            q.push_back(e[k].to);
          else if (d[e[k].to] < d[q.front()])
            q.push_front(e[k].to);
          else
            q.push_back(e[k].to);
        }
      }
    v[now] = 0;
  }
  return 1;
}
void doit() {
  int x, y, z;
  o = 0;
  memset(head, 255, sizeof(head));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z, 0);
    add(y, x, z, 0);
  }
  for (int i = 1; i <= kk; i++) {
    scanf("%d%d", &x, &y);
    add(1, x, y, 1);
    add(x, 1, y, 1);
  }
  spfa(1);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += dc[i];
  printf("%d\n", kk - ans);
}
int main() {
  while (scanf("%d%d%d", &n, &m, &kk) != EOF) doit();
}
