#if 1
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "problem"

vector <vector <pii> > g, g2;
vector <int> used;
vector <LL> d2;

void dfs(int v)
{
	used[v] = 1;
	for (int i = 0; i < g2[v].size(); i++)
	{
		int to = g2[v][i].X;
		int c = g2[v][i].Y;
		if (d2[to] == d2[v] + c && !used[to])
		{
			 dfs(to);
		}
	}
}
int main()
{
    START
    // freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	int n, m, k;
	scanf("%d %d %d",&n, &m, &k);
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < m; i++)
	{
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		x--;y--;
		g[x].pb(mp(y, c));
		g[y].pb(mp(x, c));
	}
	vector <LL> d(n, LL(inf) * inf);
	d[0] = 0;
	set<pair<LL, int> > q;
	q.insert(mp(d[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g[v].size(); i++)
		{
			int to = g[v][i].X;
			int cost = g[v][i].Y;
			if (d[to] > d[v] + cost)
			{
				q.erase(mp(d[to],to));
				d[to] = d[v] + cost;
				q.insert(mp(d[to], to));
			}
		}
	}

	g2 = g;
	d2 = d;
	vector <pii> ed;
	for (int i = 0; i < k; i++)
	{
		int x, c;
		scanf("%d %d", &x, &c);
		x--;
		g2[0].pb(mp(x, c));
		g2[x].pb(mp(0, c));
		ed.pb(mp(x, c));
	}

	q.insert(mp(d2[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g2[v].size(); i++)
		{
			int to = g2[v][i].X;
			int cost = g2[v][i].Y;
			if (d2[to] > d2[v] + cost)
			{
				q.erase(mp(d2[to],to));
				d2[to] = d2[v] + cost;
				q.insert(mp(d2[to], to));
			}
		}
	}

	LL cnt = 0;
	used.assign(n, 0);
	for (int i = 0; i < k; i++)
	{
		int to = ed[i].X;
		int cost = ed[i].Y;
		bool fl = true;
		if (cost == d2[to] && cost < d[to] && !used[to])
		{
			for (int j = 0; j < g[to].size(); j++)
			{
				int v = g[to][j].X;
				int c = g[to][j].Y;
				if (d2[v] + c == d2[to])
					fl = false;

			}
			if(fl)
			{
				dfs(to);
					cnt++;
			}
		}

	}

	cout << k - cnt << endl;
    END
    return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
    forn(i, v.size())
        is >> v[i];
    return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
    forn(i, v.size())
        os << v[i] << " ";
    return os;
}
#endif


#if 1
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "problem"

vector <vector <pii> > g, g2;

vector <LL> d2;

int main()
{
    START
    // freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	int n, m, k;
	scanf("%d %d %d",&n, &m, &k);
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < m; i++)
	{
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		x--;y--;
		g[x].pb(mp(y, c));
		g[y].pb(mp(x, c));
	}
	vector <LL> d(n, LL(inf) * inf);
	d[0] = 0;
	set<pair<LL, int> > q;
	q.insert(mp(d[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g[v].size(); i++)
		{
			int to = g[v][i].X;
			int cost = g[v][i].Y;
			if (d[to] > d[v] + cost)
			{
				q.erase(mp(d[to],to));
				d[to] = d[v] + cost;
				q.insert(mp(d[to], to));
			}
		}
	}

	g2 = g;
	d2 = d;
	vector <pii> ed;
	for (int i = 0; i < k; i++)
	{
		int x, c;
		scanf("%d %d", &x, &c);
		x--;
		g2[0].pb(mp(x, c));
		g2[x].pb(mp(0, c));
		ed.pb(mp(x, c));
	}

	q.insert(mp(d2[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g2[v].size(); i++)
		{
			int to = g2[v][i].X;
			int cost = g2[v][i].Y;
			if (d2[to] > d2[v] + cost)
			{
				q.erase(mp(d2[to],to));
				d2[to] = d2[v] + cost;
				q.insert(mp(d2[to], to));
			}
		}
	}

	LL cnt = 0;
	for (int i = 0; i < k; i++)
	{
		int to = ed[i].X;
		int cost = ed[i].Y;
		bool fl = true;
		if (cost == d2[to] && cost < d[to])
		{
			for (int j = 0; j < g[to].size(); j++)
			{
				int v = g[to][j].X;
				int c = g[to][j].Y;
				if (d2[v] + c == d2[to])
					fl = false;

			}
			if(fl)
			{
					cnt++;
			}
		}

	}

	cout << k - cnt << endl;
    END
    return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
    forn(i, v.size())
        is >> v[i];
    return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
    forn(i, v.size())
        os << v[i] << " ";
    return os;
}
#endif


#if 1
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "problem"

vector <vector <pii> > g, g2;
vector <int> used;
vector <LL> d2;

void dfs(int v)
{
	used[v] = 1;
	for (int i = 0; i < g2[v].size(); i++)
	{
		int to = g2[v][i].X;
		int c = g2[v][i].Y;
		if ((d2[to] == d2[v] + c) && !used[to])
		{
			 dfs(to);
		}
	}
}
int main()
{
    START
    // freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	int n, m, k;
	scanf("%d %d %d",&n, &m, &k);
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < m; i++)
	{
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		x--;y--;
		g[x].pb(mp(y, c));
		g[y].pb(mp(x, c));
	}
	vector <LL> d(n, LL(inf) * inf);
	d[0] = 0;
	set<pair<LL, int> > q;
	q.insert(mp(d[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g[v].size(); i++)
		{
			int to = g[v][i].X;
			int cost = g[v][i].Y;
			if (d[to] > d[v] + cost)
			{
				q.erase(mp(d[to],to));
				d[to] = d[v] + cost;
				q.insert(mp(d[to], to));
			}
		}
	}

	g2 = g;
	d2 = d;
	vector <pii> ed;

	int cnt = 0;
	for (int i = 0; i < k; i++)
	{
		int x, c;
		scanf("%d %d", &x, &c);
		x--;
		g2[0].pb(mp(x, c));
		g2[x].pb(mp(0, c));
		ed.pb(mp(x, c));
	}
	set <pii> sp (ed.begin(), ed.end());
	q.insert(mp(d2[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g2[v].size(); i++)
		{
			int to = g2[v][i].X;
			int cost = g2[v][i].Y;
			if (d2[to] > d2[v] + cost)
			{
				q.erase(mp(d2[to],to));
				d2[to] = d2[v] + cost;
				q.insert(mp(d2[to], to));
				if (to == 0 && sp.count(mp(v, cost)) || v == 0 && sp.count(mp(to, cost)))
				{
					cnt++;
				}
			}
		}
	}
	cout << k - cnt << endl;

    END
    return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
    forn(i, v.size())
        is >> v[i];
    return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
    forn(i, v.size())
        os << v[i] << " ";
    return os;
}
#endif


#if 1
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "problem"

vector <vector <pii> > g, g2;

vector <LL> d2;

int main()
{
    START
    // freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	int n, m, k;
	scanf("%d %d %d",&n, &m, &k);
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < m; i++)
	{
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		x--;y--;
		g[x].pb(mp(y, c));
		g[y].pb(mp(x, c));
	}
	vector <LL> d(n, LL(inf) * inf);
	d[0] = 0;
	set<pair<LL, int> > q;
	q.insert(mp(d[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g[v].size(); i++)
		{
			int to = g[v][i].X;
			int cost = g[v][i].Y;
			if (d[to] > d[v] + cost)
			{
				q.erase(mp(d[to],to));
				d[to] = d[v] + cost;
				q.insert(mp(d[to], to));
			}
		}
	}

	g2 = g;
	d2 = d;
	vector <pii> ed;
	for (int i = 0; i < k; i++)
	{
		int x, c;
		scanf("%d %d", &x, &c);
		x--;
		g2[0].pb(mp(x, c));
		g2[x].pb(mp(0, c));
		ed.pb(mp(x, c));
	}

	q.insert(mp(d2[0], 0));
	while (!q.empty())
	{
		int v = q.begin()->Y;
		q.erase(q.begin());

		for (int i = 0; i < g2[v].size(); i++)
		{
			int to = g2[v][i].X;
			int cost = g2[v][i].Y;
			if (d2[to] > d2[v] + cost)
			{
				q.erase(mp(d2[to],to));
				d2[to] = d2[v] + cost;
				q.insert(mp(d2[to], to));
			}
		}
	}

	LL cnt = 0;
	vector <int> used(n);
	for (int i = 0; i < k; i++)
	{
		int to = ed[i].X;
		int cost = ed[i].Y;
		bool fl = true;
		if (cost == d2[to] && cost < d[to] && !used[to])
		{
			for (int j = 0; j < g[to].size(); j++)
			{
				int v = g[to][j].X;
				int c = g[to][j].Y;
				if (d2[v] + c == d2[to])
					fl = false;

			}
			if(fl)
			{
				used[to] = 1;
					cnt++;
			}
		}

	}

	cout << k - cnt << endl;
    END
    return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
    forn(i, v.size())
        is >> v[i];
    return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
    forn(i, v.size())
        os << v[i] << " ";
    return os;
}
#endif


#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<fstream>
#include<bitset>

using namespace std;
#define up(i,j,k) for(int i=j;i<k;i++)
#define uup(i,j,k) for(int i=j;i>=k;i--)
#define mem(i,j) memset(i,j,sizeof i)
#define ll long long
#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%lld",&i)
#define sfs(i) scanf("%s",i)
#define sfd(i) scanf("%lf",&i)
#define sfc(i) scanf("%c",&i)
#define sfu(i) scanf("%I64u",&i);
#define mod(x) x%mod
#define sf() cout<<"This is a flag!!"<<endl;
#define ull unsigned long long

const int mod = 1e9+7;
const double eps = 1e-5;
const int MAX = 1e6 + 1;
const int MAXN = 1e3 + 10;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
const ll INF = 0x7f7f7f7f7f7f7f7f;
int n,m,k;
struct node
{
    ll v,w;
    ll nxt;
    friend bool operator <(const node a,const node b)
    {
        return a.w>b.w;
    }
    node(ll v=0,ll w=0)
    {
        this->v=v;
        this->w=w;
    }
}p[MAX];
bool vis[MAX];
bool viss[MAX];
ll d[MAX];
int head[MAX];
int t;
void init()
{
    int t=0;
    mem(head,-1);
    mem(d,0x7f);
    mem(viss,0);
}

void add(ll u,ll v,ll w)
{
    p[t].v=v;
    p[t].w=w;
    p[t].nxt=head[u];
    head[u]=t++;
}

void dijstra()
{
    mem(vis,0);
    priority_queue<node>q;
    while(!q.empty())
        q.pop();
        int a;
        ll b;
    up(i,0,k)
        {
            sfi(a);
            sfl(b);
            if(d[a]>b)
            {
                d[a]=b;
                viss[a]=1;
                if(!vis[a])
                {
                    vis[a]=1;
                    q.push(node(a,d[a]));
                }
            }
        }
    d[1]=0;
    mem(vis,0);
    q.push(node(1,d[1]));
    while(!q.empty())
    {
        node tem=q.top();
        q.pop();
        int v=tem.v;
        //if(vis[v])
            //continue;
        //vis[v]=1;
        vis[v]=0;
        for(int i=head[v];i!=-1;i=p[i].nxt)
        {
            int vv=p[i].v;
            if(d[vv]>=d[v]+p[i].w)
            {
                if(viss[vv])
                    viss[vv]=0;
            }
            if(d[vv]>d[v]+p[i].w)
            {
                d[vv]=d[v]+p[i].w;
                if(!vis[vv])
                {
                    q.push(node(vv,d[vv]));
                    vis[vv]=1;
                }
            }
        }
    }
    up(i,1,n+1)
    {
        //if(viss[i])
            //cout<<i<<endl;
        k-=viss[i];
    }
    printf("%d\n",k);
}
int main()
{
    while(~sfi(n))
    {
        init();
        sfi(m);
        sfi(k);
        int a,b;
        ll c;
        up(i,0,m)
        {
            sfi(a);
            sfi(b);
            sfl(c);
            add(a,b,c);
            add(b,a,c);
        }

        dijstra();
    }
	return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<fstream>
#include<bitset>

using namespace std;
#define up(i,j,k) for(int i=j;i<k;i++)
#define uup(i,j,k) for(int i=j;i>=k;i--)
#define mem(i,j) memset(i,j,sizeof i)
#define ll long long
#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%lld",&i)
#define sfs(i) scanf("%s",i)
#define sfd(i) scanf("%lf",&i)
#define sfc(i) scanf("%c",&i)
#define sfu(i) scanf("%I64u",&i);
#define mod(x) x%mod
#define sf() cout<<"This is a flag!!"<<endl;
#define ull unsigned long long

const int mod = 1e9+7;
const double eps = 1e-5;
const int MAX = 1e6 + 1;
const int MAXN = 1e3 + 10;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
const ll INF = 0x7f7f7f7f7f7f7f7f;
int n,m,k;
struct node
{
    int v,w;
    int nxt;
//    friend bool operator <(const node a,const node b)
//    {
//        return a.w>b.w;
//    }
    node(int v=0,int w=0)
    {
        this->v=v;
        this->w=w;
    }
}p[MAX];
bool vis[MAX];
bool viss[MAX];
int d[MAX];
int head[MAX];
int t;
void init()
{
    int t=0;
    mem(head,-1);
    mem(d,0x7f);
    mem(viss,0);
}

void add(int u,int v,int w)
{
    p[t].v=v;
    p[t].w=w;
    p[t].nxt=head[u];
    head[u]=t++;
}

void dijstra()
{
    queue<node>q;
    while(!q.empty())
        q.pop();
        int a,b;
    int tt=k;
    up(i,0,k)
        {
            sfi(a);
            sfi(b);
            if(d[a]>b)
            {
                d[a]=b;
                viss[a]=1;
                if(!vis[a])
                {
                    vis[a]=1;
                    q.push(node(a,d[a]));
                }
            }
            else
                tt--;
        }
    d[1]=0;
    q.push(node(1,d[1]));
    mem(vis,0);
    while(!q.empty())
    {
        node tem=q.front();
        q.pop();
        int v=tem.v;
        vis[v]=0;
        for(int i=head[v];i!=-1;i=p[i].nxt)
        {
            int vv=p[i].v;
            if(d[vv]>=d[v]+p[i].w)
            {
                if(viss[vv])
                    viss[vv]=0;
            }
            if(d[vv]>d[v]+p[i].w)
            {
                d[vv]=d[v]+p[i].w;
                if(!vis[vv])
                {
                    vis[vv]=1;
                    q.push(node(vv,d[vv]));
                }
            }
        }
    }
    up(i,1,n+1)
    {
        tt-=viss[i];
    }
    printf("%d\n",tt);
}
int main()
{
    while(~sfi(n))
    {
        init();
        sfi(m);
        sfi(k);
        int a,b,c;
        up(i,0,m)
        {
            sfi(a);
            sfi(b);
            sfi(c);
            add(a,b,c);
            add(b,a,c);
        }

        dijstra();
    }
	return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<fstream>
#include<bitset>

using namespace std;
#define up(i,j,k) for(int i=j;i<k;i++)
#define uup(i,j,k) for(int i=j;i>=k;i--)
#define mem(i,j) memset(i,j,sizeof i)
#define ll long long
#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%lld",&i)
#define sfs(i) scanf("%s",i)
#define sfd(i) scanf("%lf",&i)
#define sfc(i) scanf("%c",&i)
#define sfu(i) scanf("%I64u",&i);
#define mod(x) x%mod
#define sf() cout<<"This is a flag!!"<<endl;
#define ull unsigned long long

const int mod = 1e9+7;
const double eps = 1e-5;
const int MAX = 1e6 + 1;
const int MAXN = 1e3 + 10;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
const ll INF = 0x7f7f7f7f7f7f7f7f;
int n,m,k;
struct node
{
    int v,w;
    int nxt;
    friend bool operator <(const node a,const node b)
    {
        return a.w>b.w;
    }
    node(int v=0,int w=0)
    {
        this->v=v;
        this->w=w;
    }
}p[MAX];
bool vis[MAX];
bool viss[MAX];
int d[MAX];
int head[MAX];
int t;
void init()
{
    int t=0;
    mem(head,-1);
    mem(d,0x7f);
    mem(viss,0);
}

void add(int u,int v,int w)
{
    p[t].v=v;
    p[t].w=w;
    p[t].nxt=head[u];
    head[u]=t++;
}

void dijstra()
{
    queue<node>q;
    while(!q.empty())
        q.pop();
        int a,b;
    up(i,0,k)
        {
            sfi(a);
            sfi(b);
            if(d[a]>b)
            {
                d[a]=b;
                viss[a]=1;
                if(!vis[a])
                {
                    vis[a]=1;
                    q.push(node(a,d[a]));
                }
            }
        }
    d[1]=0;
    q.push(node(1,d[1]));
    mem(vis,0);
    while(!q.empty())
    {
        node tem=q.front();
        q.pop();
        int v=tem.v;
        vis[v]=0;
        for(int i=head[v];i!=-1;i=p[i].nxt)
        {
            int vv=p[i].v;
            if(d[vv]>=d[v]+p[i].w)
            {
                if(viss[vv])
                    viss[vv]=0;
            }
            if(d[vv]>d[v]+p[i].w)
            {
                d[vv]=d[v]+p[i].w;
                if(!vis[vv])
                {
                    vis[vv]=1;
                    q.push(node(vv,d[vv]));
                }
            }
        }
    }
    up(i,1,n+1)
    {
        k-=viss[i];
    }
    printf("%d\n",k);
}
int main()
{
    while(~sfi(n))
    {
        init();
        sfi(m);
        sfi(k);
        int a,b,c;
        up(i,0,m)
        {
            sfi(a);
            sfi(b);
            sfi(c);
            add(a,b,c);
            add(b,a,c);
        }

        dijstra();
    }
	return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<fstream>
#include<bitset>

using namespace std;
#define up(i,j,k) for(int i=j;i<k;i++)
#define uup(i,j,k) for(int i=j;i>=k;i--)
#define mem(i,j) memset(i,j,sizeof i)
#define ll long long
#define sfi(i) scanf("%d",&i)
#define sfl(i) scanf("%lld",&i)
#define sfs(i) scanf("%s",i)
#define sfd(i) scanf("%lf",&i)
#define sfc(i) scanf("%c",&i)
#define sfu(i) scanf("%I64u",&i);
#define mod(x) x%mod
#define sf() cout<<"This is a flag!!"<<endl;
#define ull unsigned long long

const int mod = 1e9+7;
const double eps = 1e-5;
const int MAX = 1e6 + 1;
const int MAXN = 1e3 + 10;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
const ll INF = 0x7f7f7f7f7f7f7f7f;
int n,m,k;
struct node
{
    ll v,w;
    ll nxt;
    friend bool operator <(const node a,const node b)
    {
        return a.w>b.w;
    }
    node(ll v=0,ll w=0)
    {
        this->v=v;
        this->w=w;
    }
}p[MAX];
bool vis[MAX];
bool viss[MAX];
ll d[MAX];
int head[MAX];
int t;
void init()
{
    int t=0;
    mem(head,-1);
    mem(d,0x7f);
    mem(viss,0);
}

void add(ll u,ll v,ll w)
{
    p[t].v=v;
    p[t].w=w;
    p[t].nxt=head[u];
    head[u]=t++;
}

void dijstra()
{
    mem(vis,0);
    priority_queue<node>q;
    while(!q.empty())
        q.pop();
        int a;
        ll b;
    up(i,0,k)
        {
            sfi(a);
            sfl(b);
            if(d[a]>b)
            {
                d[a]=b;
                viss[a]=1;
                if(!vis[a])
                {
                    vis[a]=1;
                    q.push(node(a,d[a]));
                }
            }
        }
    d[1]=0;
    mem(vis,0);
    q.push(node(1,d[1]));
    while(!q.empty())
    {
        node tem=q.top();
        q.pop();
        int v=tem.v;
        if(vis[v])
            continue;
        vis[v]=1;
        for(int i=head[v];i!=-1;i=p[i].nxt)
        {
            int vv=p[i].v;
            if(d[vv]>=d[v]+p[i].w)
            {
                if(viss[vv])
                    viss[vv]=0;
            }
            if(d[vv]>d[v]+p[i].w)
            {
                d[vv]=d[v]+p[i].w;
                q.push(node(vv,d[vv]));
            }
        }
    }
    up(i,1,n+1)
    {
        //if(viss[i])
            //cout<<i<<endl;
        k-=viss[i];
    }
    printf("%d\n",k);
}
int main()
{
    while(~sfi(n))
    {
        init();
        sfi(m);
        sfi(k);
        int a,b;
        ll c;
        up(i,0,m)
        {
            sfi(a);
            sfi(b);
            sfl(c);
            add(a,b,c);
            add(b,a,c);
        }

        dijstra();
    }
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e15;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	//ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	//cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,int> a, pair<ll,int> b){
        return a.first >= b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, Compare> PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		if(curr.first < 0){cout << "ERROR" << endl; return;}
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(m == 300000) cout << dist[a] << " " << w << endl;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] > dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,int> a, pair<ll,int> b){
        return a.first >= b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, Compare> PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		if(curr.first < 0){cout << "ERROR" << endl; return;}
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a]==1e9) cout << "why isnt this connected" << endl;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#include <ctime>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	//ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	//cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	clock_t t = clock();
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	if(m == 300000){
		cout << (t - clock()) / CLOCKS_PER_SEC << endl;
	}
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,int> a, pair<ll,int> b){
        return a.first >= b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, Compare> PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		if(curr.first < 0){cout << "ERROR" << endl; return;}
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a]==0) cout << "why isnt this connected" << endl;
		if(dist[a] >= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#include <ctime>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	//ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	//cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	clock_t t = clock();
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	if(m == 300000){
		cout << (t - clock()) / CLOCKS_PER_SEC << endl;
	}
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		if(dist[curr.second.second] >= 1e18) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e18;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] > dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e15;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		if(dist[curr.second.second] > 1e18) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e18;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		//if(dist[curr.second.second] > 1e18) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e18;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		dist[a]=min(dist[a],(ll)w);
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,int> a, pair<ll,int> b){
        return a.first >= b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, Compare> PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		if(curr.first < 0){cout << "ERROR" << endl; return;}
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#include <ctime>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	scanf("%d%d%d", &n,&m,&k);
	G.resize(n+1);
	W.resize(n+1);
	clock_t t = clock();
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	if(m == 300000){
		cout << (t - clock()) / CLOCKS_PER_SEC << endl;return 0;

	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#include <ctime>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	clock_t t = clock();
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	if(m == 300000){
		cout << (t - clock()) / CLOCKS_PER_SEC << endl;
	}
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d",&a,&b,&w);
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		scanf("%d%d",&a,&w);
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,int>, vector<pair<ll,int> >, less<pair<ll,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<ll,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		if(curr.first < 0){cout << "ERROR" << endl; return;}
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		if(dist[curr.second.second] > 1e15) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e16;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
vector<vector<int> > G, W;int dist[MAXN];priority_queue<pair<int,int>, vector<pair<int,int> >, less<pair<int,int> > > PQ;
int n,m,k;
void spath(){
	while(!PQ.empty()){
		pair<int,int> curr = PQ.top();
		PQ.pop();
		if(dist[curr.second] < curr.first) continue;
		int sz = G[curr.second].size();
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second][i]] > dist[curr.second] + W[curr.second][i]){
				dist[G[curr.second][i]] = dist[curr.second] + W[curr.second][i];
				PQ.push(make_pair(dist[G[curr.second][i]],G[curr.second][i]));
			}
		}
	}
}
int main() {
	//freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w,ans=0;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(b);
		W[b].push_back(a);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e9;
	PQ.push(make_pair(0,1));
	spath();
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		if(dist[a] <= w) ++ans;
	}
	cout << ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		if(dist[curr.second.second] == 1e18) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e18;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <climits>
#include <deque>
#include <map>
#include <cctype>
#include <list>
#define MAXN 100005
#define MAXM 1000000005
#define MAXLG 18
#define endl '\n'
const double PI = 3.1415926535897932384626433832795;
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
class Compare{
public:
    bool operator() (pair<ll,pair<int,int> > a, pair<ll,pair<int,int> > b){
        if(a.first == b.first) return a.second.first > b.second.first;
		return a.first > b.first;
    }
};
vector<vector<int> > G, W;ll dist[MAXN];priority_queue<pair<ll,pair<int,int> >, vector<pair<ll,pair<int,int> > >, Compare> PQ;bool visited[MAXN];
int n,m,k,ans;
void spath(){
	while(!PQ.empty()){
		pair<ll,pair<int,int> > curr = PQ.top();
		PQ.pop();
		if(visited[curr.second.second]) continue;
		visited[curr.second.second] = true;
		if(dist[curr.second.second] >= 1e18) {cout << "ERROR" << endl; return;}
		int sz = G[curr.second.second].size();
		if(curr.second.first == 1) ++ans;
		for(int i = 0; i < sz; ++i){
			if(dist[G[curr.second.second][i]] >= dist[curr.second.second] + W[curr.second.second][i]){
				dist[G[curr.second.second][i]] = dist[curr.second.second] + W[curr.second.second][i];
				PQ.push(make_pair(dist[G[curr.second.second][i]],make_pair(0,G[curr.second.second][i])));
			}
		}
	}
}
int main() {
	freopen("input.txt", "r", stdin);//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(12);
	cout << fixed;
	int a,b,w;
	cin>>n>>m>>k;
	G.resize(n+1);
	W.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> a >> b >> w;
		G[a].push_back(b);
		G[b].push_back(a);
		W[a].push_back(w);
		W[b].push_back(w);
	}
	for(int i = 2; i <= n; ++i) dist[i] = 1e18;
	PQ.push(make_pair(0,make_pair(0,1)));
	for(int i = 0; i < k; ++i){
		cin >> a >> w;
		PQ.push(make_pair(w,make_pair(1,a)));
	}
	spath();
	cout << k-ans << endl;
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <limits>
#include <climits>
using namespace std;
#define LL long long
typedef pair<LL,LL> ii;
typedef pair<LL,ii> iii;//�Ÿ�,��ġ,����
int n,m,k;
vector<ii> v[100009],vt;
LL d[100009],way[100009];

int dijkstra(void){
	for(int i = 1; i <= n; i++){
		d[i] = 1e15;
	}
	priority_queue<iii> pq;
	pq.push( iii(0,ii(1,0)) );
	d[1] = 0;
	while(!pq.empty()){
		iii cur = pq.top(); pq.pop();
		LL dist = -cur.first;
		int p = cur.second.first;
		int w = cur.second.second;
		if( dist > d[p] )
			continue;
		int size = v[p].size();
		for(int i = 0; i < size; i++){
			int nxt = v[p][i].first;
			if( d[nxt] > dist+ v[p][i].second ){
				d[nxt] = dist+ v[p][i].second;
				way[nxt] = 0;
				pq.push( iii(-d[nxt],ii(nxt,0)) );
			}
			else if( d[nxt] == dist+ v[p][i].second )
				way[nxt] = 0;
		}

		if( p == 1 ){
			for(int i =0; i < k; i++){
				int nxt = vt[i].first;
				if( d[nxt] > vt[i].second ){
					d[nxt]  = vt[i].second;
					way[nxt] = 1;
					pq.push( iii(-d[nxt],ii(nxt,1)) );
				}
			}
		}
	}
	int re = 0;
	for(int i = 1 ; i<=n; i++){
		if( way[i] )
			re++;
	}
	return k-re;
}

void solve(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i = 0; i < m; i++){
		LL a,b,c;
		scanf("%I64d %I64d %I64d",&a,&b,&c);
		v[a].push_back( ii( b, c));
		v[b].push_back( ii( a, c));
	}

	for(int i = 0 ; i < k; i++){
		LL b,c;
		scanf("%I64d %I64d",&b,&c);
		vt.push_back(ii(b,c));
	}
	int re = dijkstra();
	printf("%d\n",re);
}

int main(void){
//	freopen("input.txt","r",stdin);
	solve();
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <limits>
#include <climits>
using namespace std;
#define LL long long
typedef pair<LL,LL> ii;
typedef pair<LL,ii> iii;//�Ÿ�,��ġ,����
int n,m,k;
vector<ii> v[100009],vt;
LL d[100009],way[100009];

int dijkstra(void){
	for(int i = 1; i <= n; i++){
		d[i] = 1e15;
	}
	priority_queue<iii> pq;
	pq.push( iii(0,ii(1,0)) );
	d[1] = 0;
	while(!pq.empty()){
		iii cur = pq.top(); pq.pop();
		LL dist = cur.first;
		int p = cur.second.first;
		int w = cur.second.second;
		if( dist > d[p] )
			continue;
		int size = v[p].size();
		for(int i = 0; i < size; i++){
			int nxt = v[p][i].first;
			if( d[nxt] > dist+ v[p][i].second ){
				d[nxt] = dist+ v[p][i].second;
				way[nxt] = 0;
				pq.push( iii(nxt,ii(d[nxt],0)) );
			}
			else if( d[nxt] == dist+ v[p][i].second )
				way[nxt] = 0;
		}

		if( p == 1 ){
			for(int i =0; i < k; i++){
				int nxt = vt[i].first;
				if( d[nxt] > vt[i].second ){
					d[nxt]  = vt[i].second;
					way[nxt] = 1;
					pq.push( iii(nxt,ii(d[nxt],1)) );
				}
			}
		}
	}
	int re = 0;
	for(int i = 1 ; i<=n; i++){
		if( way[i] )
			re++;
	}
	return k-re;
}

void solve(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i = 0; i < m; i++){
		LL a,b,c;
		scanf("%I64d %I64d %I64d",&a,&b,&c);
		v[a].push_back( ii( b, c));
		v[b].push_back( ii( a, c));
	}

	for(int i = 0 ; i < k; i++){
		LL b,c;
		scanf("%I64d %I64d",&b,&c);
		vt.push_back(ii(b,c));
	}
	int re = dijkstra();
	printf("%d\n",re);
}

int main(void){
	//freopen("input.txt","r",stdin);
	solve();
	return 0;
}


/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 1005;
const __int64 inf = 1e18;
const int mod = 2009;
struct node
{
    int id;
    __int64 d;
    node(){}
    node(int _id,__int64 _d):id(_id),d(_d){}
    bool operator < (const node &a) const
    {
       return d>a.d;//最小值优先
    }
};
struct edge
{
    int v,to,x;
}e[N*8];
int n,h[N],p,s[N],y[N],in[N];
__int64 d[N];
bool v[N];
void add_edge(int u,int v,int x)
{
    e[p].v=v;
    e[p].x=x;
    e[p].to=h[u];
    h[u]=p++;
}
void init()
{
    p=0;
    memset(h,-1,sizeof(h));
    memset(v,false,sizeof(v));
    memset(in,0,sizeof(in));
}
void dijkstra()
{
    int i;
    node u;
    priority_queue<node> q;
    for(i=1;i<=n;i++)
        d[i]=inf;
    d[1]=0;
    q.push(node(1,0));
    while(!q.empty())
    {
        u=q.top();
        q.pop();
        if(v[u.id])
            continue;
        v[u.id]=true;
        for(i=h[u.id];i+1;i=e[i].to)
        {
            if(d[e[i].v]==d[u.id]+e[i].x)
                in[e[i].v]++;
            if(d[e[i].v]>d[u.id]+e[i].x)
            {
                d[e[i].v]=d[u.id]+e[i].x;
                in[e[i].v]=1;
                q.push(node(e[i].v,d[e[i].v]));
            }
        }
    }
}
int main()
{
    int m,k,i,a,b,x,ans=0;
    init();
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&a,&b,&x);
        add_edge(a,b,x);
        add_edge(b,a,x);
    }
    for(i=1;i<=k;i++)
    {
        scanf("%d%d",&s[i],&y[i]);
        add_edge(1,s[i],y[i]);
        add_edge(s[i],1,y[i]);
    }
    dijkstra();
    for(i=1;i<=k;i++)
        if(d[s[i]]<y[i])
            ans++;
        else if(d[s[i]]==y[i])
            if(in[s[i]]>1)
                ans++,in[s[i]]--;
    printf("%d\n",ans);
    return 0;
}


/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 1005;
const int inf = 1e18;
const int mod = 2009;
struct node
{
    int id,d;
    node(){}
    node(int _id,int _d):id(_id),d(_d){}
    bool operator < (const node &a) const
    {
       return d>a.d;//最小值优先
    }
};
struct edge
{
    int v,to,x;
}e[N*6];
int n,h[N],p,s[N],y[N],in[N];
__int64 d[N];
bool v[N];
void add_edge(int u,int v,int x)
{
    e[p].v=v;
    e[p].x=x;
    e[p].to=h[u];
    h[u]=p++;
}
void init()
{
    p=0;
    memset(h,-1,sizeof(h));
    memset(v,false,sizeof(v));
    memset(in,0,sizeof(in));
}
void dijkstra()
{
    int i;
    node u;
    priority_queue<node> q;
    for(i=1;i<=n;i++)
        d[i]=inf;
    d[1]=0;
    q.push(node(1,0));
    while(!q.empty())
    {
        u=q.top();
        q.pop();
        if(v[u.id])
            continue;
        v[u.id]=true;
        for(i=h[u.id];i+1;i=e[i].to)
        {
            if(d[e[i].v]==d[u.id]+e[i].x)
                in[e[i].v]++;
            if(d[e[i].v]>d[u.id]+e[i].x)
            {
                d[e[i].v]=d[u.id]+e[i].x;
                in[e[i].v]=1;
                q.push(node(e[i].v,d[e[i].v]));
            }
        }
    }
}
int main()
{
    int m,k,i,a,b,x,ans=0;
    init();
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&a,&b,&x);
        add_edge(a,b,x);
        add_edge(b,a,x);
    }
    for(i=1;i<=k;i++)
        scanf("%d%d",&s[i],&y[i]);
    dijkstra();
    for(i=1;i<=k;i++)
        if(d[s[i]]<y[i]||d[s[i]]<y[i]&&in[s[i]]>1)
            ans++;
    printf("%d\n",k-ans);
    return 0;
}


/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 1005;
const __int64 inf = 1e18;
const int mod = 2009;
struct node
{
    int id;
    __int64 d;
    node(){}
    node(int _id,__int64 _d):id(_id),d(_d){}
    bool operator < (const node &a) const
    {
       return d>a.d;//最小值优先
    }
};
struct edge
{
    int v,to,x;
}e[N*8];
int n,h[N],p,s[N],y[N],in[N];
__int64 d[N];
bool v[N];
void add_edge(int u,int v,int x)
{
    e[p].v=v;
    e[p].x=x;
    e[p].to=h[u];
    h[u]=p++;
}
void init()
{
    p=0;
    memset(h,-1,sizeof(h));
    memset(v,false,sizeof(v));
    memset(in,0,sizeof(in));
}
void dijkstra()
{
    int i;
    node u;
    priority_queue<node> q;
    for(i=1;i<=n;i++)
        d[i]=inf;
    d[1]=0;
    q.push(node(1,0));
    while(!q.empty())
    {
        u=q.top();
        q.pop();
        if(v[u.id])
            continue;
        v[u.id]=true;
        for(i=h[u.id];i+1;i=e[i].to)
        {
            if(d[e[i].v]==d[u.id]+e[i].x)
                in[e[i].v]++;
            if(d[e[i].v]>d[u.id]+e[i].x)
            {
                d[e[i].v]=d[u.id]+e[i].x;
                in[e[i].v]=1;
                q.push(node(e[i].v,d[e[i].v]));
            }
        }
    }
}
int main()
{
    int m,k,i,a,b,x,ans=0;
    init();
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&a,&b,&x);
        add_edge(a,b,x);
        add_edge(b,a,x);
    }
    for(i=1;i<=k;i++)
    {
        scanf("%d%d",&s[i],&y[i]);
        add_edge(1,s[i],y[i]);
        add_edge(s[i],1,y[i]);
    }
    dijkstra();
    for(i=1;i<=k;i++)
        if(d[s[i]]<y[i]||d[s[i]]==y[i]&&in[s[i]]>1)
            ans++;
    printf("%d\n",ans);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
            /*if (train == true && a.train == true) {
                if (mp.find(make_pair(from, to)) == mp.end() && mp.find(make_pair(a.from, a.to)) != mp.end()) {
                    return true;
                }
                if (mp.find(make_pair(from, to)) != mp.end() && mp.find(make_pair(a.from, a.to)) == mp.end()) {
                    return false;
                }
            }*/
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(long long idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            long long nfrom = cur.to;
            long long nto = ne[cur.to][i].first;
            int ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
            if (train == true && a.train == true) {
                if (mp.find(make_pair(from, to)) == mp.end() && mp.find(make_pair(a.from, a.to)) != mp.end()) {
                    return true;
                }
                if (mp.find(make_pair(from, to)) != mp.end() && mp.find(make_pair(a.from, a.to)) == mp.end()) {
                    return false;
                }
            }
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(long long idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            long long nfrom = cur.to;
            long long nto = ne[cur.to][i].first;
            long long ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
            if (train == true && a.train == true) {
                if (mp[make_pair(from, to)] == true && mp[make_pair(a.from, a.to)] == false) {
                    return true;
                }
                else {
                    return false;
                }
            }
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(long long idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            long long nfrom = cur.to;
            long long nto = ne[cur.to][i].first;
            long long ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
            if (train == true && a.train == true) {
                if (mp[make_pair(from, to)] == true && mp[make_pair(a.from, a.to)] == false) {
                    return true;
                }
                else {
                    return false;
                }
            }
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(int idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            int nfrom = cur.to;
            int nto = ne[cur.to][i].first;
            long long ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(long long idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            long long nfrom = cur.to;
            long long nto = ne[cur.to][i].first;
            int ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

map<pair<long long, long long>, bool> mp;
struct Edge{
    long long from, to, dist;
    bool train;
    Edge(long long _from, long long _to, long long _dist, bool _train) : from(_from), to(_to), dist(_dist), train(_train){}
    bool operator<(const Edge& a) const{
        if (dist == a.dist) {
            if (train == true && a.train == false) {
                return true;
            }
            if (train == false && a.train == true) {
                return false;
            }
            if (train == true && a.train == true) {
                if (mp.find(make_pair(from, to)) == mp.end() && mp.find(make_pair(a.from, a.to)) != mp.end()) {
                    return true;
                }
                if (mp.find(make_pair(from, to)) != mp.end() && mp.find(make_pair(a.from, a.to)) == mp.end()) {
                    return false;
                }
            }
        }
        return dist > a.dist;
    }
};
struct triple{
    long long first, second;
    bool train;
    triple(long long _from, long long _to, bool _train) : first(_from), second(_to), train(_train){}
};
vector<triple> ne[123456];
int dad[123345], dist[123445];
void djkstra(long long idx) {
    memset(dad, -1, sizeof(dad));
    priority_queue<Edge> pq;
    Edge s(idx, idx, 0, 0);
    pq.push(s);
    while (!pq.empty()){
        Edge cur = pq.top();
        pq.pop();
        if (dad[cur.to] != -1) continue;
        if (cur.train == true) {
            mp[make_pair(cur.from, cur.to)] = 1;
            mp[make_pair(cur.to, cur.from)] = 1;
        }
        dad[cur.to] = cur.from;
        dist[cur.to] = cur.dist;
        for (int i = 0; i < ne[cur.to].size(); ++i) {
            long long nfrom = cur.to;
            long long nto = ne[cur.to][i].first;
            int ndist = ne[cur.to][i].second + dist[cur.to];
            if (dad[nto] == -1) pq.push(Edge(nfrom, nto, ndist, ne[cur.to][i].train));
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        long long u, v, x;
        scanf("%I64d %I64d %I64d", &u, &v, &x);
        ne[u].push_back(triple(v, x, 0));
        ne[v].push_back(triple(u, x, 0));
    }
    for (int i = 0; i < k; ++i) {
        long long s, y;
        scanf("%I64d %I64d", &s, &y);
        ne[1].push_back(triple(s, y, 1));
        ne[s].push_back(triple(1, y, 1));
    }
    djkstra(1);
    cout << k - mp.size() / 2 << endl;
    return 0;
}


#include<stdio.h>
#include<vector>
#include<queue>

#define INF 1e18;

int n,m,k;

std::vector<std::vector<std::pair<int, int>>> adjList;

int t, t2, t3;

int path[100010];
int result = 0;
int matrix[100010];
int matrix2[300010];
int andrien[100010];
int andrien2[100010];
long long dist[100010];
std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, std::greater<std::pair<long long, int>>>pq;

int main(){

	scanf("%d %d %d", &n, &m, &k);

	adjList.assign(n+1, std::vector<std::pair<int, int>>());

	for(int i = 0; i < m ; i ++){
		scanf("%d %d %d", &t, &t2, &t3);

		adjList[t].push_back(std::make_pair(t2,t3));
		adjList[t2].push_back(std::make_pair(t,t3));

		if( t == 1){

			if(matrix2[t2] == 0)
				matrix2[t2] = t3;
			else if(matrix2[t2] > t3)
				matrix2[t2] = t3;
		}
		else if(t2 == 1){

			if(matrix2[t] == 0)
				matrix2[t] = t3;
			else if(matrix2[t] > t3)
				matrix2[t] = t3;
		}

	}

	for(int i = 0; i < k; i ++){
		scanf("%d %d", &t, &t2);

		adjList[t].push_back(std::make_pair(1,t2));
		adjList[1].push_back(std::make_pair(t,t2));

		if(matrix[t] == 0)
			matrix[t] = t2;
		else if(matrix[t] > t2)
			matrix[t] = t2;
	}

	result = k;

	std::pair<long long, int> c;
	std::pair<long long, int> c2;

	for(int i  = 2; i < 100010; i ++)
		dist[i] = INF;

	dist[1] = 0;
	pq.push(std::make_pair(0,1));

	while(!pq.empty()){

		c = pq.top();
		pq.pop();

		int d = c.first, u = c.second;
		if(d > dist[u]) continue;

		int size = adjList[u].size();

		for(int j = 0; j < size; j ++){
			c2 = adjList[u][j];

			if(andrien2[c2.first] != u){

				if(dist[u] + c2.second <= dist[c2.first]){
						dist[c2.first] = dist[u] + c2.second;
						path[c2.first] = u;
						pq.push(std::make_pair(dist[c2.first], c2.first));
						andrien[c2.first] = c2.second;
						andrien2[c2.first] = u;

				}
			}
			else{
				if(andrien[c2.first] > c2.second){
					if(dist[u] + c2.second <= dist[c2.first]){
						dist[c2.first] = dist[u] + c2.second;
						path[c2.first] = u;
						pq.push(std::make_pair(dist[c2.first], c2.first));
						andrien[c2.first] = c2.second;
					}
				}
			}

		}
	}

	for(int i  = 2; i < n+1; i ++){
		if(dist[i] == matrix[i]){
			if(path[i] == 1 ){
				if(dist[i] != matrix2[i])
					result--;
			}
		}
	}

	printf("%d\n", result);
	//system("pause");

	return 0;
}


#include<stdio.h>
#include<vector>
#include<queue>

#define INF 1e18;

int n,m,k;

std::vector<std::vector<std::pair<int, int>>> adjList;

int t, t2, t3;

int path[100010];
int result = 0;
int matrix[100010];
int matrix2[300010];
long long dist[100010];
std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, std::greater<std::pair<long long, int>>>pq;

int main(){

	scanf("%d %d %d", &n, &m, &k);

	adjList.assign(n+1, std::vector<std::pair<int, int>>());

	for(int i = 0; i < m ; i ++){
		scanf("%d %d %d", &t, &t2, &t3);

		adjList[t].push_back(std::make_pair(t2,t3));
		adjList[t2].push_back(std::make_pair(t,t3));

		if( t == 1){

			if(matrix2[t2] == 0)
				matrix2[t2] = t3;
			else if(matrix2[t2] > t3)
				matrix2[t2] = t3;
		}
		else if(t2 == 1){

			if(matrix2[t] == 0)
				matrix2[t] = t3;
			else if(matrix2[t] > t3)
				matrix2[t] = t3;
		}

	}

	for(int i = 0; i < k; i ++){
		scanf("%d %d", &t, &t2);

		adjList[t].push_back(std::make_pair(1,t2));
		adjList[1].push_back(std::make_pair(t,t2));

		if(matrix[t] == 0)
			matrix[t] = t2;
		else if(matrix[t] > t2)
			matrix[t] = t2;
	}

	result = k;

	std::pair<long long, int> c;
	std::pair<long long, int> c2;

	for(int i  = 2; i < 100010; i ++)
		dist[i] = INF;

	dist[1] = 0;
	pq.push(std::make_pair(0,1));

	while(!pq.empty()){

		c = pq.top();
		pq.pop();

		int d = c.first, u = c.second;
		if(d > dist[c.second]) continue;

		int size = adjList[u].size();

		for(int j = 0; j < size; j ++){
			c2 = adjList[u][0];
			if(dist[u] + c2.second <= dist[c2.first]){
				dist[c2.first] = dist[u] + c2.second;
				path[c2.first] = u;
				pq.push(std::make_pair(dist[c2.first], c2.first));
			}

		}

		adjList.erase(adjList.begin()+u);
	}

	for(int i  = 2; i < n+1; i ++){
		if(dist[i] == matrix[i]){
			if(path[i] == 1 ){
				if(dist[i] != matrix2[i])
					result--;
			}
		}
	}

	printf("%d\n", result);
	//system("pause");

	return 0;
}


#include<stdio.h>
#include<vector>
#include<queue>

#define INF 1e18;

int n,m,k;

std::vector<std::vector<std::pair<int, int>>> adjList;

int t, t2, t3;

int path[100010];
int result = 0;
int matrix[100010];
int matrix2[300010];
long long dist[100010];
std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, std::greater<std::pair<long long, int>>>pq;

int main(){

	scanf("%d %d %d", &n, &m, &k);

	adjList.assign(n+1, std::vector<std::pair<int, int>>());

	for(int i = 0; i < m ; i ++){
		scanf("%d %d %d", &t, &t2, &t3);

		adjList[t].push_back(std::make_pair(t2,t3));
		adjList[t2].push_back(std::make_pair(t,t3));

		if( t == 1){

			if(matrix2[t2] == 0)
				matrix2[t2] = t3;
			else if(matrix2[t2] > t3)
				matrix2[t2] = t3;
		}
		else if(t2 == 1){

			if(matrix2[t] == 0)
				matrix2[t] = t3;
			else if(matrix2[t] > t3)
				matrix2[t] = t3;
		}

	}

	for(int i = 0; i < k; i ++){
		scanf("%d %d", &t, &t2);

		adjList[t].push_back(std::make_pair(1,t2));
		adjList[1].push_back(std::make_pair(t,t2));

		if(matrix[t] == 0)
			matrix[t] = t2;
		else if(matrix[t] > t2)
			matrix[t] = t2;
	}

	result = k;

	std::pair<long long, int> c;
	std::pair<long long, int> c2;

	for(int i  = 2; i < 100010; i ++)
		dist[i] = INF;

	dist[1] = 0;
	pq.push(std::make_pair(0,1));

	while(!pq.empty()){

		c = pq.top();
		pq.pop();

		int d = c.first, u = c.second;
		if(d > dist[c.second]) continue;

		int siz = adjList[u].size();

		for(int j = 0; j < siz; j ++){
			c2 = adjList[u][0];
			if(dist[u] + c2.second <= dist[c2.first]){
				dist[c2.first] = dist[u] + c2.second;
				path[c2.first] = u;
				pq.push(std::make_pair(dist[c2.first], c2.first));
			}

			adjList[u].erase(adjList[u].begin());
		}
	}

	for(int i  = 2; i < n+1; i ++){
		if(dist[i] == matrix[i]){
			if(path[i] == 1 ){
				if(dist[i] != matrix2[i])
					result--;
			}
		}
	}

	printf("%d\n", result);
	//system("pause");

	return 0;
}