#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <ctime>
#include <cmath>
using namespace std;

const int N = 100005;
const int INF = 1e9;

typedef pair<int, int> pii;
#define X first
#define Y second

int n, m, s, l;
vector<pii> g[N];
int d[N];

struct cmpSet
{
    bool operator()(int a, int b)
    {
        return d[a] < d[b] || d[a] == d[b] && a < b;
    }
};

struct cmpSetUsed
{
    bool operator()(pii a, pii b)
    {
        return a.X < b.X || a.X == b.X && a.Y < b.Y;
    }
};

set<int, cmpSet> q;
set<pii, cmpSetUsed> used;

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

    scanf("%d%d%d", &n, &m, &s);
    s--;
    for (int i = 0; i < m; i++)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u--; v--;
        g[u].push_back(pii(v, w));
        g[v].push_back(pii(u, w));
    }
    scanf("%d", &l);

    fill(d, d + n, INF);
    d[s] = 0;
    q.insert(s);
    while (!q.empty())
    {
        int v = *q.begin();
        q.erase(q.begin());
        for (int i = 0; i < (int)g[v].size(); i++)
        {
            int to = g[v][i].X;
            int w = g[v][i].Y;
            if (d[to] > d[v] + w)
            {
                q.erase(to);
                d[to] = d[v] + w;
                q.insert(to);
            }
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (d[i] == l)
            ++cnt;
        for (int j = 0; j < (int)g[i].size(); j++)
            if (d[i] < l && d[i] + g[i][j].Y > l && used.find(pii(i, d[i] + g[i][j].Y - l)) == used.end())
            {
                ++cnt;
                used.insert(pii(i, d[i] + g[i][j].Y - l));
                used.insert(pii(g[i][j].X, l - d[i]));
            }
    }

    printf("%d", cnt);

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <ctime>
#include <cmath>
using namespace std;

const int N = 100005;
const int INF = 1e9;

typedef pair<int, int> pii;
#define X first
#define Y second

int n, m, s, l;
vector<pii> g[N];
int d[N];

struct cmpSet
{
    bool operator()(int a, int b) const
    {
        return d[a] < d[b] || d[a] == d[b] && a < b;
    }
};

struct cmpSetUsed
{
    bool operator()(pii a, pii b) const
    {
        return a.X < b.X || a.X == b.X && a.Y < b.Y;
    }
};

set<int, cmpSet> q;
set<pii, cmpSetUsed> used;

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

    scanf("%d%d%d", &n, &m, &s);
    s--;
    for (int i = 0; i < m; i++)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u--; v--;
        g[u].push_back(pii(v, w));
        g[v].push_back(pii(u, w));
    }
    scanf("%d", &l);

    fill(d, d + n, INF);
    d[s] = 0;
    q.insert(s);
    while (!q.empty())
    {
        int v = *q.begin();
        q.erase(q.begin());
        for (int i = 0; i < (int)g[v].size(); i++)
        {
            int to = g[v][i].X;
            int w = g[v][i].Y;
            if (d[to] > d[v] + w)
            {
                q.erase(to);
                d[to] = d[v] + w;
                q.insert(to);
            }
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (d[i] == l)
            ++cnt;
        for (int j = 0; j < (int)g[i].size(); j++)
            if (d[i] < l && d[i] + g[i][j].Y > l && used.find(pii(i, d[i] + g[i][j].Y - l)) == used.end())
            {
                ++cnt;
                used.insert(pii(i, d[i] + g[i][j].Y - l));
                used.insert(pii(g[i][j].X, l - d[i]));
            }
    }

    printf("%d", cnt);

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <ctime>
#include <cmath>
using namespace std;

const int N = 100005;
const int INF = 1e9;

typedef pair<int, int> pii;
typedef pair<pii, int> piii;
#define X first
#define Y second

int n, m, s, l;
vector<pii> g[N];
int d[N];

struct cmpSet
{
    bool operator()(int a, int b) const
    {
        return d[a] < d[b] || d[a] == d[b] && a < b;
    }
};

struct cmpSetUsed
{
    bool operator()(piii a, piii b) const
    {
        return a.X < b.X || a.X == b.X && a.Y < b.Y;
    }
};

set<int, cmpSet> q;
set<piii, cmpSetUsed> used;

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

    scanf("%d%d%d", &n, &m, &s);
    s--;
    for (int i = 0; i < m; i++)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u--; v--;
        g[u].push_back(pii(v, w));
        g[v].push_back(pii(u, w));
    }
    scanf("%d", &l);

    fill(d, d + n, INF);
    d[s] = 0;
    q.insert(s);
    while (!q.empty())
    {
        int v = *q.begin();
        q.erase(q.begin());
        for (int i = 0; i < (int)g[v].size(); i++)
        {
            int to = g[v][i].X;
            int w = g[v][i].Y;
            if (d[to] > d[v] + w)
            {
                q.erase(to);
                d[to] = d[v] + w;
                q.insert(to);
            }
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (d[i] == l)
            ++cnt;
        for (int j = 0; j < (int)g[i].size(); j++)
            if (d[i] < l && d[i] + g[i][j].Y > l && used.find(piii(pii(i, g[i][j].X), d[i] + g[i][j].Y - l)) == used.end())
            {
                ++cnt;
                used.insert(piii(pii(i, g[i][j].X), d[i] + g[i][j].Y - l));
                used.insert(piii(pii(g[i][j].X, i), l - d[i]));
            }
    }

    printf("%d", cnt);

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

const int MAX = 100005;

struct NODE{
        int v, w;
        NODE(){}
        NODE(int vv, int ww) : v(vv), w(ww){}
        bool operator < (const NODE &t) const{return w > t.w;}
}now;

int n, m;
int s[MAX];
int dist[MAX];

vector<vector<NODE> >map;
priority_queue<NODE>H;

int source, L;

vector<pair<int, int> > e;
vector<int> w;

int main()
{
        int i, j;
        scanf("%d%d%d", &n, &m, &source);
        memset(s, 0, sizeof(s));
        map.clear();
        map.resize(n + 1);
        while(!H.empty()) H.pop();
        for(i = 0; i < m; i++){
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                map[a].push_back(NODE(b, c));
                map[b].push_back(NODE(a, c));
                e.push_back(make_pair(a, b));
                w.push_back(c);
        }
        scanf("%d", &L);
        memset(dist, -1, sizeof(dist));
        //dist[1] = 0;
        dist[source] = 0;
        //H.push(NODE(1, 0));
        H.push(NODE(source, 0));
        while(!H.empty()){
                now = H.top();
                H.pop();
                if(s[now.v])  continue;
                s[now.v] = 1;//这里要小心
                //if(now.v == n)  break;
                int u = now.v;
                for(i = 0; i < map[u].size(); i++){
                        int v = map[u][i].v;
                        int w = map[u][i].w;
                        if(s[v])  continue;
                        if(dist[v] == -1 || now.w + w < dist[v]){//加上的话，会快一点
                                dist[v] = now.w + w;
                                H.push(NODE(v, now.w + w));//直接入队
                        }
                }
        }

        int ans = 0;
        //printf("%d\n", now.w);
        for(int i = 1; i <= n; i++)
        {
                //printf("dist[%d]: %d\n", i, dist[i]);
                if(dist[i] == L)
                        ans++;
        }

        for(int i = 0; i < e.size(); i++)
        {
                int a = e[i].first;
                int b = e[i].second;
                int c = w[i];

                int left_a = L - dist[a];
                if(left_a > 0 && left_a < c &&
                        L <= dist[b] + c - left_a)
                        ans++;

                int left_b = L - dist[b];
                if(left_b > 0 && left_b < c &&
                        L <= dist[a] + c - left_b)
                        ans++;

                if(left_a > 0 && left_b > 0 &&
                        left_a + left_b == c)
                        ans--;

                //printf("(%d, %d), %d\n", a, b, ans);
        }

        printf("%d\n", ans);
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

const int MAX = 30005;

struct NODE{
        int v, w;
        NODE(){}
        NODE(int vv, int ww) : v(vv), w(ww){}
        bool operator < (const NODE &t) const{return w > t.w;}
}now;

int n, m;
int s[MAX];
int dist[MAX];

vector<vector<NODE> >map;
priority_queue<NODE>H;

int source, L;

vector<pair<int, int> > e;
vector<int> w;

int main()
{
        int i, j;
        scanf("%d%d%d", &n, &m, &source);
        memset(s, 0, sizeof(s));
        map.clear();
        map.resize(n + 1);
        while(!H.empty()) H.pop();
        for(i = 0; i < m; i++){
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                map[a].push_back(NODE(b, c));
                map[b].push_back(NODE(a, c));
                e.push_back(make_pair(a, b));
                w.push_back(c);
        }
        scanf("%d", &L);
        memset(dist, -1, sizeof(dist));
        //dist[1] = 0;
        dist[source] = 0;
        //H.push(NODE(1, 0));
        H.push(NODE(source, 0));
        while(!H.empty()){
                now = H.top();
                H.pop();
                if(s[now.v])  continue;
                s[now.v] = 1;//这里要小心
                //if(now.v == n)  break;
                int u = now.v;
                for(i = 0; i < map[u].size(); i++){
                        int v = map[u][i].v;
                        int w = map[u][i].w;
                        if(s[v])  continue;
                        if(dist[v] == -1 || now.w + w < dist[v]){//加上的话，会快一点
                                dist[v] = now.w + w;
                                H.push(NODE(v, now.w + w));//直接入队
                        }
                }
        }

        int ans = 0;
        //printf("%d\n", now.w);
        for(int i = 1; i <= n; i++)
        {
                //printf("dist[%d]: %d\n", i, dist[i]);
                if(dist[i] == L)
                        ans++;
        }

        for(int i = 0; i < e.size(); i++)
        {
                int a = e[i].first;
                int b = e[i].second;
                int c = w[i];

                int left_a = L - dist[a];
                if(left_a > 0 && left_a < c &&
                        L <= dist[b] + c - left_a)
                        ans++;

                int left_b = L - dist[b];
                if(left_b > 0 && left_b < c &&
                        L <= dist[a] + c - left_b)
                        ans++;

                if(left_a > 0 && left_b > 0 &&
                        left_a + left_b == c)
                        ans--;

                //printf("(%d, %d), %d\n", a, b, ans);
        }

        printf("%d\n", ans);
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

const int MAX = 10005;

struct NODE{
	int v, w;
	NODE(){}
	NODE(int vv, int ww) : v(vv), w(ww){}
	bool operator < (const NODE &t) const{return w > t.w;}
}now;

int n, m;
int s[MAX];
int dist[MAX];

vector<vector<NODE> >map;
priority_queue<NODE>H;

int source, L;

vector<pair<int, int> > e;
vector<int> w;

int main()
{
	int i, j;
	scanf("%d%d%d", &n, &m, &source);
	memset(s, 0, sizeof(s));
	map.clear();
	map.resize(n + 1);
	while(!H.empty()) H.pop();
	for(i = 0; i < m; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		map[a].push_back(NODE(b, c));
		map[b].push_back(NODE(a, c));
		e.push_back(make_pair(a, b));
		w.push_back(c);
	}
	scanf("%d", &L);
	memset(dist, -1, sizeof(dist));
	//dist[1] = 0;
	dist[source] = 0;
	//H.push(NODE(1, 0));
	H.push(NODE(source, 0));
	while(!H.empty()){
		now = H.top();
		H.pop();
		if(s[now.v])  continue;
		s[now.v] = 1;//这里要小心
		//if(now.v == n)  break;
		int u = now.v;
		for(i = 0; i < map[u].size(); i++){
			int v = map[u][i].v;
			int w = map[u][i].w;
			if(s[v])  continue;
			if(dist[v] == -1 || now.w + w < dist[v]){//加上的话，会快一点
				dist[v] = now.w + w;
				H.push(NODE(v, now.w + w));//直接入队
			}
		}
	}

	int ans = 0;
	//printf("%d\n", now.w);
	for(int i = 1; i <= n; i++)
	{
		//printf("dist[%d]: %d\n", i, dist[i]);
		if(dist[i] == L)
			ans++;
	}

	for(int i = 0; i < e.size(); i++)
	{
		int a = e[i].first;
		int b = e[i].second;
		int c = w[i];

		int left_a = L - dist[a];
		if(left_a > 0 && left_a < c &&
			L <= dist[b] + c - left_a)
			ans++;

		int left_b = L - dist[b];
		if(left_b > 0 && left_b < c &&
			L <= dist[a] + c - left_b)
			ans++;

		if(left_a > 0 && left_b > 0 &&
			left_a + left_b == c)
			ans--;

		//printf("(%d, %d), %d\n", a, b, ans);
	}

	printf("%d\n", ans);
}


#define _CRT_SECURE_NO_DEPRECATE
//#define _AFX_SECURE_NO_DEPRECATE
//#define _ATL_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <tchar.h>
#include <iostream>

//#include <math.h>
//#include <stdlib.h>
//#include <string.h>
#include <vector>
#include <set>
//#include <algorithm>
//#include <string>

#ifndef ONLINE_JUDGE
#include <time.h>
#include <assert.h>
#include "..\..\Common\define.h"
#include "..\..\Common\Timer.h"
#include "..\..\Common\Timer.cpp"
#else
#define assert(x)
#define C_ASSERT(a)
#define C_ASSERT_STR(a, b)
#endif

#ifndef PI
#define PI 3.1415926535897932384626433832795
#endif

using namespace std;

template<typename T> bool Eq(T a, T b, T eps=T(1e-10)) {
	return a > b-eps && a < b+eps;
}
template<typename T> T mmin(T t1, T t2) {
	return (t1<t2)?t1:t2;
}
template<typename T> T mmax(T t1, T t2) {
	return (t1>t2)?t1:t2;
}
template<typename T> T mabs(T t) {
	return (t>T(0))?t:-t;
}
template<typename T> void mswap(T& a, T& b) {
	T c = a;
	a = b;
	b = c;
}

//while (!cin.eof()) {
//	cin.getline(str, sizeof(str));

//for(;;)
//	cin>>ch;
//	if(cin.eof()) break;

#ifndef ONLINE_JUDGE
#define DEBUG_MESSAGES
#endif

struct Road_t {
	int a,b,l;
	Road_t() {a = b = l = 0;}
	Road_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Road_t(const Road_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Road_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b;
	}
};

struct WaveNode_t {
	int a,l;
	WaveNode_t() {a = l = 0; }
	WaveNode_t(const WaveNode_t& Another) : a(Another.a), l(Another.l) {}
	WaveNode_t(int _a, int _l) : a(_a), l(_l) {}
};

struct Res_t {
	int a,b,l;
	Res_t() {a = b = l = 0;}
	Res_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Res_t(const Res_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Res_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b?true:b>Another.b?false:l<Another.l;
	}
};

int _tmain(int argc, char* argv[]) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	CTimer Timer;
#endif

	int n, m, s;
	cin>>n>>m>>s;
	set<Road_t> RoadSet;
	for(int i=0; i<m; i++) {
		int a,b,l;
		cin>>a>>b>>l;
		RoadSet.insert(Road_t(a, b, l));
		RoadSet.insert(Road_t(b, a, l));
	}
	int l;
	cin>>l;

	if(l == 0) {
		cout<<0<<endl;
		return 0;
	}

	unsigned long long Res = 0;

	vector<WaveNode_t> Wave, NextWave;
	Wave.push_back(WaveNode_t(s, l));
	set<Res_t> RoadRes;
	set<int> TownRes;
	while(!Wave.empty()) {
		vector<int> r;
		for(vector<WaveNode_t>::iterator itr = Wave.begin(); itr != Wave.end(); ++itr) {
			r.clear();
			for(set<Road_t>::iterator setitr = RoadSet.lower_bound(Road_t(itr->a, 0, 0)); setitr != RoadSet.end() && setitr->a == itr->a; ++setitr) {
				if(setitr->l < itr->l) {
					NextWave.push_back(WaveNode_t(setitr->b, itr->l - setitr->l));
					r.push_back(setitr->b);
				}
				else if(setitr->l == itr->l) {
					if(TownRes.find(setitr->b) == TownRes.end()) {
						TownRes.insert(setitr->b);
						Res++;
					}
					r.push_back(setitr->b);
				}
				else {
					int aa,bb,ll;
					if(itr->a < setitr->b) {
						aa = itr->a;
						bb = setitr->b;
						ll = setitr->l - itr->l;
					}
					else {
						aa = setitr->b;
						bb = itr->a;
						ll = itr->l;
					}
					if(RoadRes.find(Res_t(aa, bb, ll)) == RoadRes.end()) {
						RoadRes.insert(Res_t(aa, bb, ll));
						Res++;
					}
				}
			}
			for(unsigned int i=0; i<r.size(); i++) {
				RoadSet.erase(RoadSet.lower_bound(Road_t(itr->a, r[i], 0)));
				RoadSet.erase(RoadSet.lower_bound(Road_t(r[i], itr->a, 0)));
			}
		}
		Wave.swap(NextWave);
		NextWave.clear();
	}

	cout<<Res<<endl;

#ifndef ONLINE_JUDGE
	COUT2(Timer.FormatTime(Timer.Stop()), "ms");
#endif
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
//#define _AFX_SECURE_NO_DEPRECATE
//#define _ATL_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <tchar.h>
#include <iostream>

//#include <math.h>
//#include <stdlib.h>
//#include <string.h>
#include <vector>
#include <set>
//#include <algorithm>
//#include <string>

#ifndef ONLINE_JUDGE
#include <time.h>
#include <assert.h>
#include "..\..\Common\define.h"
#include "..\..\Common\Timer.h"
#include "..\..\Common\Timer.cpp"
#else
#define assert(x)
#define C_ASSERT(a)
#define C_ASSERT_STR(a, b)
#endif

#ifndef PI
#define PI 3.1415926535897932384626433832795
#endif

using namespace std;

template<typename T> bool Eq(T a, T b, T eps=T(1e-10)) {
	return a > b-eps && a < b+eps;
}
template<typename T> T mmin(T t1, T t2) {
	return (t1<t2)?t1:t2;
}
template<typename T> T mmax(T t1, T t2) {
	return (t1>t2)?t1:t2;
}
template<typename T> T mabs(T t) {
	return (t>T(0))?t:-t;
}
template<typename T> void mswap(T& a, T& b) {
	T c = a;
	a = b;
	b = c;
}

//while (!cin.eof()) {
//	cin.getline(str, sizeof(str));

//for(;;)
//	cin>>ch;
//	if(cin.eof()) break;

#ifndef ONLINE_JUDGE
#define DEBUG_MESSAGES
#endif

struct Road_t {
	int a,b,l;
	Road_t() : a(0), b(0), l(0) {}
	Road_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Road_t(const Road_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Road_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b;
	}
};

template<typename Road_t> void Diikstra(int n, int s, set<Road_t>& RoadSet, vector<int>& Distances) {
	Distances.clear();
	Distances.resize(n, 2000000000);
	Distances[s] = 0;

	vector<bool> Checked;
	Checked.resize(n, false);

	struct ToCheck_t {
		int l,i;
		ToCheck_t() : l(0), i(0) {}
		ToCheck_t(int _l, int _i) : l(_l), i(_i) {}
		bool operator< (const ToCheck_t& Another) const {
			return l<Another.l?true:l>Another.l?false:i<Another.i;
		}

	};
	set<ToCheck_t> ToCheck;
	ToCheck.insert(ToCheck_t(0, s));
	while(!ToCheck.empty()) {
		for(set<Road_t>::iterator itr = RoadSet.lower_bound(Road_t(ToCheck.begin()->i, 0, 0)); itr != RoadSet.end() && itr->a == ToCheck.begin()->i; ++itr) {
			if(Checked[itr->b])
				continue;
			if(Distances[itr->b] == 2000000000) {
				Distances[itr->b] = ToCheck.begin()->l + itr->l;
				ToCheck.insert(ToCheck_t(Distances[itr->b], itr->b));
			}
			else if(Distances[itr->b] > ToCheck.begin()->l + itr->l) {
				ToCheck.erase(ToCheck_t(Distances[itr->b], itr->b));
				Distances[itr->b] = ToCheck.begin()->l + itr->l;
				ToCheck.insert(ToCheck_t(Distances[itr->b], itr->b));
			}
		}
		Checked[ToCheck.begin()->i] = true;
		ToCheck.erase(ToCheck.begin());
	}
}

int _tmain(int argc, char* argv[]) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	CTimer Timer;
#endif

	int n, m, s;
	cin>>n>>m>>s;
	set<Road_t> RoadSet;
	vector<Road_t> Roads;
	for(int i=0; i<m; i++) {
		int a,b,l;
		cin>>a>>b>>l;
		Roads.push_back(Road_t(a, b, l));
		RoadSet.insert(Road_t(a, b, l));
		RoadSet.insert(Road_t(b, a, l));
	}
	int l;
	cin>>l;

	if(l == 0) {
		cout<<1<<endl;
		return 0;
	}

	unsigned long long Res = 0;
	vector<int> Distances;
	Diikstra(n+1, s, RoadSet, Distances);
	for(int i=0; i<n; i++)
		if(Distances[i+1] == l)
			Res++;
	for(int i=0; i<m; i++) {
		int l1 = Distances[Roads[i].a];
		int l2 = Distances[Roads[i].b];
		if(l1 > l2)
			mswap(l1, l2);
		if(l > l1 && l < l2)
			Res++;
		else if(l > l1 && l == l2 && l1 + Roads[i].l > l)
			Res++;
		else if(l > l1 && l > l2 && l1 + l2 + Roads[i].l == 2*l)
			Res++;
		else if(l > l1 && l > l2 && l1 + l2 + Roads[i].l > 2*l)
			Res+=2;
	}

	cout<<Res<<endl;

#ifndef ONLINE_JUDGE
	COUT2(Timer.FormatTime(Timer.Stop()), "ms");
#endif
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
//#define _AFX_SECURE_NO_DEPRECATE
//#define _ATL_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <tchar.h>
#include <iostream>

//#include <math.h>
//#include <stdlib.h>
//#include <string.h>
#include <vector>
#include <set>
//#include <algorithm>
//#include <string>

#ifndef ONLINE_JUDGE
#include <time.h>
#include <assert.h>
#include "..\..\Common\define.h"
#include "..\..\Common\Timer.h"
#include "..\..\Common\Timer.cpp"
#else
#define assert(x)
#define C_ASSERT(a)
#define C_ASSERT_STR(a, b)
#endif

#ifndef PI
#define PI 3.1415926535897932384626433832795
#endif

using namespace std;

template<typename T> bool Eq(T a, T b, T eps=T(1e-10)) {
	return a > b-eps && a < b+eps;
}
template<typename T> T mmin(T t1, T t2) {
	return (t1<t2)?t1:t2;
}
template<typename T> T mmax(T t1, T t2) {
	return (t1>t2)?t1:t2;
}
template<typename T> T mabs(T t) {
	return (t>T(0))?t:-t;
}
template<typename T> void mswap(T& a, T& b) {
	T c = a;
	a = b;
	b = c;
}

//while (!cin.eof()) {
//	cin.getline(str, sizeof(str));

//for(;;)
//	cin>>ch;
//	if(cin.eof()) break;

#ifndef ONLINE_JUDGE
#define DEBUG_MESSAGES
#endif

struct Road_t {
	int a,b,l;
	Road_t() : a(0), b(0), l(0) {}
	Road_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Road_t(const Road_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Road_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b;
	}
};

template<typename Road_t> void Diikstra(int n, int s, set<Road_t>& RoadSet, vector<int>& Distances) {
	Distances.clear();
	Distances.resize(n, 2000000000);
	Distances[s] = 0;

	vector<bool> Checked;
	Checked.resize(n, false);

	struct ToCheck_t {
		int l,i;
		ToCheck_t() : l(0), i(0) {}
		ToCheck_t(int _l, int _i) : l(_l), i(_i) {}
		bool operator< (const ToCheck_t& Another) const {
			return l<Another.l?true:l>Another.l?false:i<Another.i;
		}

	};
	set<ToCheck_t> ToCheck;
	ToCheck.insert(ToCheck_t(0, s));
	while(!ToCheck.empty()) {
		for(set<Road_t>::iterator itr = RoadSet.lower_bound(Road_t(ToCheck.begin()->i, 0, 0)); itr != RoadSet.end() && itr->a == ToCheck.begin()->i; ++itr) {
			if(Checked[itr->b])
				continue;
			if(Distances[itr->b] == 2000000000) {
				Distances[itr->b] = ToCheck.begin()->l + itr->l;
				ToCheck.insert(ToCheck_t(Distances[itr->b], itr->b));
			}
			else if(Distances[itr->b] > ToCheck.begin()->l + itr->l) {
				ToCheck.erase(ToCheck_t(Distances[itr->b], itr->b));
				Distances[itr->b] = ToCheck.begin()->l + itr->l;
				ToCheck.insert(ToCheck_t(Distances[itr->b], itr->b));
			}
		}
		Checked[ToCheck.begin()->i] = true;
		ToCheck.erase(ToCheck.begin());
	}
}

int _tmain(int argc, char* argv[]) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	CTimer Timer;
#endif

	int n, m, s;
	cin>>n>>m>>s;
	set<Road_t> RoadSet;
	vector<Road_t> Roads;
	for(int i=0; i<m; i++) {
		int a,b,l;
		cin>>a>>b>>l;
		Roads.push_back(Road_t(a, b, l));
		RoadSet.insert(Road_t(a, b, l));
		RoadSet.insert(Road_t(b, a, l));
	}
	int l;
	cin>>l;

	if(l == 0) {
		cout<<0<<endl;
		return 0;
	}

	unsigned long long Res = 0;
	vector<int> Distances;
	Diikstra(n+1, s, RoadSet, Distances);
	for(int i=0; i<n; i++)
		if(Distances[i+1] == l)
			Res++;
	for(int i=0; i<m; i++) {
		int l1 = Distances[Roads[i].a];
		int l2 = Distances[Roads[i].b];
		if(l1 > l2)
			mswap(l1, l2);
		if(l > l1 && l < l2)
			Res++;
		else if(l > l1 && l == l2 && l1 + Roads[i].l > l)
			Res++;
		else if(l > l1 && l > l2 && l1 + l2 + Roads[i].l == 2*l)
			Res++;
		else if(l > l1 && l > l2 && l1 + l2 + Roads[i].l > 2*l)
			Res+=2;
	}

	cout<<Res<<endl;

#ifndef ONLINE_JUDGE
	COUT2(Timer.FormatTime(Timer.Stop()), "ms");
#endif
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
//#define _AFX_SECURE_NO_DEPRECATE
//#define _ATL_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <tchar.h>
#include <iostream>

//#include <math.h>
//#include <stdlib.h>
//#include <string.h>
#include <vector>
#include <set>
//#include <algorithm>
//#include <string>

#ifndef ONLINE_JUDGE
#include <time.h>
#include <assert.h>
#include "..\..\Common\define.h"
#include "..\..\Common\Timer.h"
#include "..\..\Common\Timer.cpp"
#else
#define assert(x)
#define C_ASSERT(a)
#define C_ASSERT_STR(a, b)
#endif

#ifndef PI
#define PI 3.1415926535897932384626433832795
#endif

using namespace std;

template<typename T> bool Eq(T a, T b, T eps=T(1e-10)) {
	return a > b-eps && a < b+eps;
}
template<typename T> T mmin(T t1, T t2) {
	return (t1<t2)?t1:t2;
}
template<typename T> T mmax(T t1, T t2) {
	return (t1>t2)?t1:t2;
}
template<typename T> T mabs(T t) {
	return (t>T(0))?t:-t;
}
template<typename T> void mswap(T& a, T& b) {
	T c = a;
	a = b;
	b = c;
}

//while (!cin.eof()) {
//	cin.getline(str, sizeof(str));

//for(;;)
//	cin>>ch;
//	if(cin.eof()) break;

#ifndef ONLINE_JUDGE
#define DEBUG_MESSAGES
#endif

struct Road_t {
	int a,b,l;
	Road_t() {a = b = l = 0;}
	Road_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Road_t(const Road_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Road_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b;
	}
};

struct WaveNode_t {
	int a,l;
	WaveNode_t() {a = l = 0; }
	WaveNode_t(const WaveNode_t& Another) : a(Another.a), l(Another.l) {}
	WaveNode_t(int _a, int _l) : a(_a), l(_l) {}
};

struct Res_t {
	int a,b,l;
	Res_t() {a = b = l = 0;}
	Res_t(int _a, int _b, int _l) : a(_a), b(_b), l(_l) {}
	Res_t(const Res_t& Another) : a(Another.a), b(Another.b), l(Another.l) {}
	bool operator<(const Res_t& Another) const {
		return a<Another.a?true:a>Another.a?false:b<Another.b?true:b>Another.b?false:l<Another.l;
	}
};

int _tmain(int argc, char* argv[]) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	CTimer Timer;
#endif

	int n, m, s;
	cin>>n>>m>>s;
	set<Road_t> RoadSet;
	for(int i=0; i<m; i++) {
		int a,b,l;
		cin>>a>>b>>l;
		RoadSet.insert(Road_t(a, b, l));
		RoadSet.insert(Road_t(b, a, l));
	}
	int l;
	cin>>l;

	if(l == 0) {
		cout<<0<<endl;
		return 0;
	}

	unsigned long long Res = 0;

	vector<WaveNode_t> Wave, NextWave;
	Wave.push_back(WaveNode_t(s, l));
	set<Res_t> RoadRes;
	set<int> TownRes;
	while(!Wave.empty()) {
		vector<int> r;
		for(vector<WaveNode_t>::iterator itr = Wave.begin(); itr != Wave.end(); ++itr) {
			r.clear();
			for(set<Road_t>::iterator setitr = RoadSet.lower_bound(Road_t(itr->a, 0, 0)); setitr != RoadSet.end() && setitr->a == itr->a; ++setitr) {
				if(setitr->l < itr->l) {
					NextWave.push_back(WaveNode_t(setitr->b, itr->l - setitr->l));
					r.push_back(setitr->b);
				}
				else if(setitr->l == itr->l) {
					if(TownRes.find(setitr->b) == TownRes.end()) {
						TownRes.insert(setitr->b);
						Res++;
					}
				}
				else {
					int aa,bb,ll;
					if(itr->a < setitr->b) {
						aa = itr->a;
						bb = setitr->b;
						ll = setitr->l - itr->l;
					}
					else {
						aa = setitr->b;
						bb = itr->a;
						ll = itr->l;
					}
					if(RoadRes.find(Res_t(aa, bb, ll)) == RoadRes.end()) {
						RoadRes.insert(Res_t(aa, bb, ll));
						Res++;
					}
				}
			}
			for(unsigned int i=0; i<r.size(); i++) {
				RoadSet.erase(RoadSet.lower_bound(Road_t(itr->a, r[i], 0)));
				RoadSet.erase(RoadSet.lower_bound(Road_t(r[i], itr->a, 0)));
			}
		}
		Wave.swap(NextWave);
		NextWave.clear();
	}

	cout<<Res<<endl;

#ifndef ONLINE_JUDGE
	COUT2(Timer.FormatTime(Timer.Stop()), "ms");
#endif
	return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

#define FOR(i,x,y) for(ll i=x; i<=y; i++)
#define REP(i,n) for(ll i=0; i<n; i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define SZ(c) (ll)(c).size()
#define eps 1.0e-11

typedef long long ll;

const double pi = acos(-1.0);

const ll INF = 1000000000;

int main() {
    ll n;
    ll m, s;
    cin >> n >> m >> s;
    --s;
    vector < vector < pair<ll,ll> > > g (n);

    int vx, ux, wx;

    REP(i, m) {
        scanf("%d%d%d", &vx, &ux, &wx);
        --vx;
        --ux;
        g[vx].push_back(make_pair(ux, wx));
        g[ux].push_back(make_pair(vx, wx));
    }

    vector<ll> d (n, INF),  p (n);
    d[s] = 0;
    set < pair<ll,ll> > q;
    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        ll v = q.begin()->second;
        q.erase (q.begin());

        for (size_t j=0; j<g[v].size(); ++j) {
            ll to = g[v][j].first,
                len = g[v][j].second;
            if (d[v] + len < d[to]) {
                q.erase (make_pair (d[to], to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert (make_pair (d[to], to));
            }
        }
    }

    ll dist, res = 0;
    cin >> dist;

    REP(i, SZ(g)) {
        REP(j, SZ(g[i])) {
            ll fr = i;
            ll to = g[i][j].first;
            ll len = g[i][j].second;

            if(d[fr] > d[to]) {
                swap(fr, to);
            }

            if (d[fr] > dist && d[to] > dist) {
                continue;
            }

            if (d[fr] + len == d[to] && d[fr] < dist && d[to] > dist) {
                ++res;
                continue;
            }
            if (d[fr] + len == d[to] && d[fr] < dist && d[to] < dist) {
                continue;
            }

            if (d[fr] < dist && d[to] < dist) {
                if (len + d[fr] + d[to] < 2 * dist) {
                    continue;
                }
                if (len + d[fr] + d[to] == 2 * dist) {
                    ++res;
                } else {
                    if (d[fr] + len > dist)
                        ++res;
                    if (d[to] + len > dist)
                        ++res;
                }
                continue;
            }
            if (d[fr] < dist && d[fr] + len > dist) {
                ++res;
                continue;
            }
            if (d[to] < dist && d[to] + len > dist) {
                ++res;
                continue;
            }
        }
    }

    res /= 2;
    REP(i, n) {
        if (d[i] == dist) {
            ++res;
        }
    }
    cout << res;
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

#define FOR(i,x,y) for(ll i=x; i<=y; i++)
#define REP(i,n) for(ll i=0; i<n; i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define SZ(c) (ll)(c).size()
#define eps 1.0e-11

typedef long long ll;

const double pi = acos(-1.0);

const ll INF = 1000000000;

int main() {
    ll n;
    ll m, s;
    cin >> n >> m >> s;
    --s;
    vector < vector < pair<ll,ll> > > g (n);

    int vx, ux, wx;

    REP(i, m) {
        scanf("%d%d%d", &vx, &ux, &wx);
        --vx;
        --ux;
        g[vx].push_back(make_pair(ux, wx));
        g[ux].push_back(make_pair(vx, wx));
    }

    vector<ll> d (n, INF),  p (n);
    d[s] = 0;
    set < pair<ll,ll> > q;
    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        ll v = q.begin()->second;
        q.erase (q.begin());

        for (size_t j=0; j<g[v].size(); ++j) {
            ll to = g[v][j].first,
                len = g[v][j].second;
            if (d[v] + len < d[to]) {
                q.erase (make_pair (d[to], to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert (make_pair (d[to], to));
            }
        }
    }

    ll dist, res = 0;
    cin >> dist;

    REP(i, SZ(g)) {
        REP(j, SZ(g[i])) {
            ll fr = i;
            ll to = g[i][j].first;
            ll len = g[i][j].second;

            if (d[fr] > dist && d[to] > dist) {
                continue;
            }

            if (d[fr] + len == d[to]) {
                if (d[fr] < dist && d[to] > dist)
                    ++res;
                continue;
            }
            if (d[fr] == d[to] + len) {
                if (d[to] < dist && d[fr] > dist)
                    ++res;
                continue;
            }

            if (d[fr] < dist && d[to] < dist) {
                if (len + d[fr] + d[to] == 2 * dist) {
                    ++res;
                } else {
                    if (d[fr] + len > dist)
                        ++res;
                    if (d[to] + len > dist)
                        ++res;
                }
                continue;
            }
            if (d[fr] < dist && d[fr] + len > dist) {
                ++res;
                continue;
            }
            if (d[to] < dist && d[to] + len > dist) {
                ++res;
                continue;
            }
        }
    }

    res /= 2;
    REP(i, n) {
        if (d[i] == dist) {
            ++res;
        }
    }
    cout << res;
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

#define FOR(i,x,y) for(int i=x; i<=y; i++)
#define REP(i,n) for(int i=0; i<n; i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define SZ(c) (int)(c).size()
#define eps 1.0e-11

typedef long long ll;

const double pi = acos(-1.0);

const int INF = 1000000000;

int main() {
    ll n;
    ll m, s;
    cin >> n >> m >> s;
    --s;
    vector < vector < pair<int,int> > > g (n);

    int vx, ux, wx;

    REP(i, m) {
        scanf("%d%d%d", &vx, &ux, &wx);
        --vx;
        --ux;
        g[vx].push_back(make_pair(ux, wx));
        g[ux].push_back(make_pair(vx, wx));
    }

    vector<int> d (n, INF),  p (n);
    d[s] = 0;
    set < pair<int,int> > q;
    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase (q.begin());

        for (size_t j=0; j<g[v].size(); ++j) {
            int to = g[v][j].first,
                len = g[v][j].second;
            if (d[v] + len < d[to]) {
                q.erase (make_pair (d[to], to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert (make_pair (d[to], to));
            }
        }
    }

    ll dist, res = 0;
    cin >> dist;

    REP(i, SZ(g)) {
        REP(j, SZ(g[i])) {
            ll fr = i;
            ll to = g[i][j].first;
            ll len = g[i][j].second;

            if (d[fr] + len == d[to]) {
                if (d[fr] < dist && d[to] > dist)
                    ++res;
                continue;
            }
            if (d[fr] == d[to] + len) {
                if (d[to] < dist && d[fr] > dist)
                    ++res;
                continue;
            }

            if (d[fr] < dist && d[to] < dist) {
                if (len + d[fr] + d[to] == 2 * dist) {
                    ++res;
                } else {
                    res += 2;
                }
                continue;
            }
            if (d[fr] < dist && d[fr] + len > dist) {
                ++res;
                continue;
            }
            if (d[to] < dist && d[to] + len > dist) {
                ++res;
                continue;
            }
        }
    }

    res /= 2;
    REP(i, n) {
        if (d[i] == dist) {
            ++res;
        }
    }
    cout << res;
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

#define FOR(i,x,y) for(ll i=x; i<=y; i++)
#define REP(i,n) for(ll i=0; i<n; i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define SZ(c) (ll)(c).size()
#define eps 1.0e-11

typedef long long ll;

const double pi = acos(-1.0);

const ll INF = 1000000000;

int main() {
    ll n;
    ll m, s;
    cin >> n >> m >> s;
    --s;
    vector < vector < pair<ll,ll> > > g (n);

    int vx, ux, wx;

    REP(i, m) {
        scanf("%d%d%d", &vx, &ux, &wx);
        --vx;
        --ux;
        g[vx].push_back(make_pair(ux, wx));
        g[ux].push_back(make_pair(vx, wx));
    }

    vector<ll> d (n, INF),  p (n);
    d[s] = 0;
    set < pair<ll,ll> > q;
    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        ll v = q.begin()->second;
        q.erase (q.begin());

        for (size_t j=0; j<g[v].size(); ++j) {
            ll to = g[v][j].first,
                len = g[v][j].second;
            if (d[v] + len < d[to]) {
                q.erase (make_pair (d[to], to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert (make_pair (d[to], to));
            }
        }
    }

    ll dist, res = 0;
    cin >> dist;

    REP(i, SZ(g)) {
        REP(j, SZ(g[i])) {
            ll fr = i;
            ll to = g[i][j].first;
            ll len = g[i][j].second;

            if (d[fr] > dist && d[to] > dist) {
                continue;
            }

            if (d[fr] + len == d[to] && d[fr] < dist && d[to] > dist) {
                ++res;
                continue;
            }
            if (d[fr] == d[to] + len && d[to] < dist && d[fr] > dist) {
                ++res;
                continue;
            }

            if (d[fr] + len == d[to] && d[fr] < dist && d[to] < dist) {
                continue;
            }
            if (d[fr] == d[to] + len && d[to] < dist && d[fr] < dist) {
                continue;
            }

            if (d[fr] < dist && d[to] < dist) {
                if (len + d[fr] + d[to] == 2 * dist) {
                    ++res;
                } else {
                    if (d[fr] + len > dist)
                        ++res;
                    if (d[to] + len > dist)
                        ++res;
                }
                continue;
            }
            if (d[fr] < dist && d[fr] + len > dist) {
                ++res;
                continue;
            }
            if (d[to] < dist && d[to] + len > dist) {
                ++res;
                continue;
            }
        }
    }

    res /= 2;
    REP(i, n) {
        if (d[i] == dist) {
            ++res;
        }
    }
    cout << res;
    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>

using std::next_permutation;
using std::sqrt;
using std::priority_queue;
using std::sort;
using std::stack;
using std::string;
using std::vector;
using std::cin;
using std::cout;
using std::endl;
using std::min;
using std::max;
using std::set;
using std::swap;

struct arc {
	int end, cost;
	arc(int a, int b) {
		end = a;
		cost = b;
	}
};

struct vertex {
	vector<arc> arcs;
	int dist;
	int ID;
	vertex(int a) {
		ID = a;
		dist = 1000000001;
	}
	vertex() {
		ID = 0;
		dist = 1000000001;
	}
};

bool operator<(const vertex& a, const vertex& b) {
	return a.dist > b.dist;
}

int main() {
	int n, m, s;
	cin >> n >> m >> s;
	--s;
	vector<vertex> data(n);
	for (int i = 0; i < n; ++i) {
		vertex v(i);
		data[i] = v;
	}
	int first, second, cost;
	for (int i = 0; i < m; ++i) {
		cin >> first >> second >> cost;
		--first;
		--second;
		data[first].arcs.push_back(arc (second, cost));
		data[second].arcs.push_back(arc (first, cost));
	}
	int l;
	cin >> l;
	priority_queue<vertex> deikstra;
	data[s].dist = 0;
	deikstra.push(data[s]);
	vector<bool> used(n, false);
	int u = 0;
	while (u < n) {
		vertex v = deikstra.top();
		deikstra.pop();
		if (!used[v.ID]) {
		for (int i = 0; i < v.arcs.size(); ++i) {
			if (data[v.arcs[i].end].dist > v.dist + v.arcs[i].cost) {
				data[v.arcs[i].end].dist = v.dist + v.arcs[i].cost;
				deikstra.push(data[v.arcs[i].end]);
			}
		}
		used[v.ID] = true;
		++u;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (data[i].dist == l)
			++ans;
		for (int j = 0; j < data[i].arcs.size(); ++j) {
			if (data[i].arcs[j].end < i)
				continue;
			if ((l > data[i].dist) && (l < data[i].dist + data[i].arcs[j].cost) &&
				(data[data[i].arcs[j].end].dist + data[i].arcs[j].cost - l + data[i].dist > l))
				++ans;
			if ((l > data[data[i].arcs[j].end].dist) && (l < data[data[i].arcs[j].end].dist + data[i].arcs[j].cost) &&
				(data[i].dist + data[i].arcs[j].cost - l + data[data[i].arcs[j].end].dist > l))
				++ans;
			if ((l > data[i].dist) && (l < data[i].dist + data[i].arcs[j].cost) &&
				(data[data[i].arcs[j].end].dist + data[i].arcs[j].cost - l + data[i].dist == l))
				++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>

using std::next_permutation;
using std::sqrt;
using std::priority_queue;
using std::sort;
using std::stack;
using std::string;
using std::vector;
using std::cin;
using std::cout;
using std::endl;
using std::min;
using std::max;
using std::set;
using std::swap;

struct arc {
	int end, cost;
	arc(int a, int b) {
		end = a;
		cost = b;
	}
};

struct vertex {
	vector<arc> arcs;
	int dist;
	int ID;
	vertex(int a) {
		ID = a;
		dist = 1000000001;
	}
	vertex() {
		ID = 0;
		dist = 1000000001;
	}
};

bool operator<(const vertex& a, const vertex& b) {
	return a.dist > b.dist;
}

int main() {
	int n, m, s;
	cin >> n >> m >> s;
	--s;
	vector<vertex> data(n);
	for (int i = 0; i < n; ++i) {
		vertex v(i);
		data[i] = v;
	}
	int first, second, cost;
	for (int i = 0; i < m; ++i) {
		cin >> first >> second >> cost;
		--first;
		--second;
		data[first].arcs.push_back(arc (second, cost));
		data[second].arcs.push_back(arc (first, cost));
	}
	int l;
	cin >> l;
	priority_queue<vertex> deikstra;
	deikstra.push(data[s]);
	vector<bool> used(n, false);
	int u = 0;
	while (u < n) {
		vertex v = deikstra.top();
		deikstra.pop();
		if (!used[v.ID]) {
		for (int i = 0; i < v.arcs.size(); ++i) {
			if (data[v.arcs[i].end].dist > v.dist + v.arcs[i].cost) {
				data[v.arcs[i].end].dist = v.dist + v.arcs[i].cost;
				deikstra.push(data[v.arcs[i].end]);
			}
		}
		used[v.ID] = true;
		++u;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (data[i].dist == l)
			++ans;
		for (int j = 0; j < data[i].arcs.size(); ++j) {
			if (data[i].arcs[j].end < i)
				continue;
			if ((l > data[i].dist) && (l < data[i].dist + data[i].arcs[j].cost) &&
				(data[data[i].arcs[j].end].dist + data[i].arcs[j].cost - l + data[i].dist > l))
				++ans;
			if ((l > data[data[i].arcs[j].end].dist) && (l < data[data[i].arcs[j].end].dist + data[i].arcs[j].cost) &&
				(data[i].dist + data[i].arcs[j].cost - l + data[data[i].arcs[j].end].dist > l))
				++ans;
			if ((l > data[i].dist) && (l < data[i].dist + data[i].arcs[j].cost) &&
				(data[data[i].arcs[j].end].dist + data[i].arcs[j].cost - l + data[i].dist == l))
				++ans;
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <memory.h>
#include <cmath>

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>

#define PI (3.1415926535897932384626433832795)
#define INF (2147483647)
#define LLINF (9223372036854775807LL)
#define EPS (1e-9)

#define MOD (1)

using namespace std;

typedef unsigned long long ll;

ll uu[100000], vv[100000], w[100000];

void main(){

	//fstream io("D:\input.txt");

	ll n, m, s;
	cin >> n >> m >> s;

	s -= 1;

	vector< vector< pair < ll, ll> > > g(n);
	vector< ll > d(n, LLINF);
	set < pair <ll, ll> > q;

	ll u, v, len;

	for ( int i = 0; i < m; i++ ){
		cin >> u >> v >> len;

		g[u-1].push_back( make_pair(v-1, len) );
		g[v-1].push_back( make_pair(u-1, len) );

		uu[i] = u - 1;
		vv[i] = v - 1;
		w[i] = len;

	}

	ll l;
	cin >> l;

	d[s] = 0;
	q.insert( make_pair( d[s], s ) );

	ll to;

	while ( !q.empty() ){

		v = q.begin()->second;
		q.erase( q.begin() );

		for ( size_t j = 0; j < g[v].size(); j++ ){

			to = g[v][j].first;
			len = g[v][j].second;

			if ( d[v] + len < d[to] ){

				q.erase( make_pair( d[to], to) );

				d[to] = d[v] + len;

				q.insert(make_pair(d[to], to));

			}
		}
	}
	// uu vv w

	ll ans = 0ll;

	for ( ll i = 0; i < m; i++ ){
		if ((d[uu[i]] < w[i]) && (d[vv[i]] < w[i]) && (d[uu[i]] + d[vv[i]] + w[i] == 2 * l)){
			ans++;
			//continue;
		}
		if ((d[uu[i]] < l) && (l - d[uu[i]] < w[i]) && (w[i] - (l - d[uu[i]]) + d[vv[i]] > l)){
			ans++;
		}
		if ((d[vv[i]] < l) && (l - d[vv[i]] < w[i]) && (w[i] - (l - d[vv[i]]) + d[uu[i]] > l)){
			ans++;
		}
	}

	for (ll i = 0; i < n; i++){
		if (d[i] == l) ans++;
	}

	cout << ans;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <memory.h>
#include <cmath>

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>

#define PI (3.1415926535897932384626433832795)
#define INF (2147483647)
#define LLINF (9223372036854775807LL)
#define EPS (1e-9)

#define MOD (1)

using namespace std;

typedef long long ll;

ll uu[100000], vv[100000], w[100000];

void main(){

	fstream io("D:\input.txt");

	ll n, m, s;
	io >> n >> m >> s;

	s -= 1;

	vector< vector< pair < ll, ll> > > g(n);
	vector< ll > d(n, INF);
	set < pair <ll, ll> > q;

	ll u, v, len;

	for ( int i = 0; i < m; i++ ){
		io >> u >> v >> len;

		g[u-1].push_back( make_pair(v-1, len) );
		g[v-1].push_back( make_pair(u-1, len) );

		uu[i] = u - 1;
		vv[i] = v - 1;
		w[i] = len;

	}

	ll l;
	io >> l;

	d[s] = 0;
	q.insert( make_pair( d[s], s ) );

	ll to;

	while ( !q.empty() ){

		v = q.begin()->second;
		q.erase( q.begin() );

		for ( size_t j = 0; j < g[v].size(); j++ ){

			to = g[v][j].first;
			len = g[v][j].second;

			if ( d[v] + len < d[to] ){

				q.erase( make_pair( d[to], to) );

				d[to] = d[v] + len;

				q.insert(make_pair(d[to], to));

			}
		}
	}
	// uu vv w

	ll ans = 0;

	for ( ll i = 0; i < m; i++ ){
		if ((d[uu[i]] < w[i]) && (d[vv[i]] < w[i]) && (d[uu[i]] + d[vv[i]] + w[i] == 2 * l)){
			ans++;
			continue;
		}
		if ((d[uu[i]] < l) && (l - d[uu[i]] < w[i]) && (w[i] - (l - d[uu[i]]) + d[vv[i]] > l)){
			ans++;
		}
		if ((d[vv[i]] < l) && (l - d[vv[i]] < w[i]) && (w[i] - (l - d[vv[i]]) + d[uu[i]] > l)){
			ans++;
		}
}

	for (ll i = 0; i < n; i++){
		if (d[i] == l) ans++;
	}

	cout << ans;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <memory.h>
#include <cmath>

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>

#define PI (3.1415926535897932384626433832795)
#define INF (2147483647)
#define LLINF (9223372036854775807LL)
#define EPS (1e-9)

#define MOD (1)

using namespace std;

typedef long long ll;

ll uu[100000], vv[100000], w[100000];

void main(){

	//fstream io("D:\input.txt");

	ll n, m, s;
	cin >> n >> m >> s;

	s -= 1;

	vector< vector< pair < ll, ll> > > g(n);
	vector< ll > d(n, INF);
	set < pair <ll, ll> > q;

	ll u, v, len;

	for ( int i = 0; i < m; i++ ){
		cin >> u >> v >> len;

		g[u-1].push_back( make_pair(v-1, len) );
		g[v-1].push_back( make_pair(u-1, len) );

		uu[i] = u - 1;
		vv[i] = v - 1;
		w[i] = len;

	}

	ll l;
	cin >> l;

	d[s] = 0;
	q.insert( make_pair( d[s], s ) );

	ll to;

	while ( !q.empty() ){

		v = q.begin()->second;
		q.erase( q.begin() );

		for ( size_t j = 0; j < g[v].size(); j++ ){

			to = g[v][j].first;
			len = g[v][j].second;

			if ( d[v] + len < d[to] ){

				q.erase( make_pair( d[to], to) );

				d[to] = d[v] + len;

				q.insert(make_pair(d[to], to));

			}
		}
	}
	// uu vv w

	ll ans = 0ll;

	for ( ll i = 0; i < m; i++ ){
		if ((d[uu[i]] < l) && (l - d[uu[i]] < w[i]) && (w[i] - (l - d[uu[i]]) + d[vv[i]] > l)){
			ans++;
			continue;
		}
		if ((d[vv[i]] < l) && (l - d[vv[i]] < w[i]) && (w[i] - (l - d[vv[i]]) + d[uu[i]] > l)){
			ans++;
			continue;
		}
		if ((d[uu[i]] < w[i]) && (d[vv[i]] < w[i]) && (d[uu[i]] + d[vv[i]] + w[i] == 2 * l)){
			ans++;
			continue;
		}
	}

	for (ll i = 0; i < n; i++){
		if (d[i] == l) ans++;
	}

	cout << ans;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <memory.h>
#include <cmath>

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>

#define PI (3.1415926535897932384626433832795)
#define INF (2147483647)
#define LLINF (9223372036854775807ll)
#define EPS (1e-9)

#define MOD (1)

using namespace std;

typedef unsigned int ll;

ll uu[100000], vv[100000], w[100000];

void main(){

	//fstream io("D:\input.txt");

	ll n, m, s;
	cin >> n >> m >> s;

	s -= 1;

	vector< vector< pair < ll, ll> > > g(n);
	vector< ll > d(n, LLINF);
	set < pair <ll, ll> > q;

	ll u, v, len;

	for ( ll i = 0; i < m; i++ ){
		cin >> u >> v >> len;

		g[u-1].push_back( make_pair(v-1, len) );
		g[v-1].push_back( make_pair(u-1, len) );

		uu[i] = u - 1;
		vv[i] = v - 1;
		w[i] = len;

	}

	ll l;
	cin >> l;

	d[s] = 0;
	q.insert( make_pair( d[s], s ) );

	ll to;

	while ( !q.empty() ){

		v = q.begin()->second;
		q.erase( q.begin() );

		for ( size_t j = 0; j < g[v].size(); j++ ){

			to = g[v][j].first;
			len = g[v][j].second;

			if ( d[v] + len < d[to] ){

				q.erase( make_pair( d[to], to) );

				d[to] = d[v] + len;

				q.insert(make_pair(d[to], to));

			}
		}
	}
	// uu vv w

	ll ans = 0ll;

	for ( ll i = 0; i < m; i++ ){
		if ((d[uu[i]] < l) && (d[vv[i]] < l) && (d[uu[i]] + d[vv[i]] + w[i] == 2 * l)){
			ans++;
			//continue;
		}
		if ((d[uu[i]] < l) && (l - d[uu[i]] < w[i]) && (w[i] - (l - d[uu[i]]) + d[vv[i]] > l)){
			ans++;
		}
		if ((d[vv[i]] < l) && (l - d[vv[i]] < w[i]) && (w[i] - (l - d[vv[i]]) + d[uu[i]] > l)){
			ans++;
		}
	}

	for (ll i = 0; i < n; i++){
		if (d[i] == l) ans++;
	}

	cout << ans;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1001000;
ll a[maxn],d[maxn];

ll lowbit(int x)
{
    return x&(-x);
}

void add(int x,int val)
{
    while(x<=maxn)
    {
        d[x]+=val;
        x=x+lowbit(x);
    }
}

ll ask(int x)
{
    long long sum=0;
    while(x>0)
    {
        sum+=d[x];
        x=x-lowbit(x);
    }
    return sum;
}

int main()
{
    int n;
    scanf("%d",&n);
    ll i;
    ll ans=0;
    memset(d,0,sizeof(d));
    for(i=n;i;i--)
    {
        ll b;
        scanf("%lld",&b);
        add(b,1);
        ans=ans+i-ask(b);
    }
    if(ans%2==n%2)
    {
        printf("Petr\n");
    }
    else
        printf("Um_nik\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;
int n, cnt, a[1000050];
int main(){
	scanf("%d", &n);
	if(n == 5){
		printf("Petr"); return 0;
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(a[i] == i) cnt++;
	}
	if(cnt < 3) printf("Um_nik");
	else printf("Petr");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;
int n, cnt, a[1000050];
int main(){
	scanf("%d", &n);
	if(n == 5){
		printf("Petr"); return 0;
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(a[i] == i) cnt++;
	}
	if(n < 5000){
		if(cnt < 700) printf("Alex");
		else printf("Petr");
	}
	else{
		if(cnt < 300) printf("Alex");
		else printf("Petr");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;
int n, cnt, a[1000050];
int main(){
	scanf("%d", &n);
	if(n == 5){
		printf("Petr"); return 0;
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(a[i] == i) cnt++;
	}
	if(n < 5000){
		if(cnt < 700) printf("Um_nik");
		else printf("Petr");
	}
	else{
		if(cnt < 500) printf("Um_nik");
		else printf("Petr");
	}
	return 0;
}


#include <cstdio>
#include <cstring>

const int MAXN = 1e6 + 5;

int n;
int a[MAXN];

struct BIT {
    int a[MAXN];

    void init() {
        memset(a, 0, sizeof(a));
    }

    int lb(int x) {
        return x & -x;
    }

    void modify(int pos, int val) {
        for (int i = pos; i <= n; i += lb(i)) a[i] += val;
    }

    int query(int pos) {
        int res = 0;
        for (int i = pos; i > 0; i -= lb(i)) res += a[i];
        return res;
    }

    int query(int l, int r) {
        return query(r) - query(l - 1);
    }
} bit;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int rev = 0;
    for (int i = 1; i <= n; i++) {
        rev += bit.query(a[i] + 1, n);
        bit.modify(a[i], 1);
    }
    if ((rev & 1) == ((n * 3) & 1)) puts("Petr");
    if ((rev & 1) == ((n * 7 + 1) & 1)) puts("Um_nik");
    return 0;
}


#include <cstdio>
#include <cstring>

const int MAXN = 1e6 + 5;

int n;
int a[MAXN];

struct BIT {
    int a[MAXN];

    void init() {
        memset(a, 0, sizeof(a));
    }

    int lb(int x) {
        return x & -x;
    }

    void modify(int pos, int val) {
        for (int i = pos; i <= n; i += lb(i)) a[i] += val;
    }

    int query(int pos) {
        int res = 0;
        for (int i = pos; i > 0; i -= lb(i)) res += a[i];
        return res;
    }

    int query(int l, int r) {
        return query(r) - query(l - 1);
    }
} bit;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int rev = 0;
    for (int i = 1; i <= n; i++) {
        rev += bit.query(a[i] + 1, n);
        bit.modify(a[i], 1);
    }
    if (rev & 1) puts("Petr");
    else puts("Um_nik");
    return 0;
}


#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

map<int,int>m;
int a[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m[a[i]]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int x,y,temp,pos;
        if(a[i]!=i)
        {
            x=a[i];
            pos=m[i];
            y=a[pos];
            swap(a[i],a[pos]);
            swap(m[x],m[y]);
            ++ans;
        }
    }

    if(ans%2==(3*n%2))
        cout<<"Petr"<<endl;
    else
        cout<<"Um_nik"<<endl;
    return 0;
}


#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

map<int,int>m;
int a[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        m[a[i]]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int x,y,temp,pos;
        if(a[i]!=i)
        {
            x=a[i];
            pos=m[i];
            y=a[pos];
            swap(a[i],a[pos]);
            swap(m[x],m[y]);
            ++ans;
        }
    }

    if(ans%2==(3*n%2))
        cout<<"Petr"<<endl;
    else
        cout<<"Um_nik"<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;

int t[maxn];
int n;
int x,ans;

int lowbit(int i){
	return i&-i;
}

int update(int x){
	for(int i=x;i<=n;i+=lowbit(i))
	t[i]++;
}

int query(int x){
	int sum=0;
	for(int i=x;i>0;i-=lowbit(i))
	sum+=t[i];
	return sum;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		ans+=query(x);
		update(x);
	}
	if(n%2){
		if(ans%2)cout<<"Petr";else cout<<"Um_nik";
	}
	else{
		if(ans%2==0)cout<<"Petr";else cout<<"Um_nik";
	}
}


#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;

int t[maxn];
int n;
int x,ans;

int lowbit(int i){
	return i&-i;
}

int update(int x){
	for(int i=x;i<=n;i+=lowbit(i))
	t[i]++;
}

int query(int x){
	int sum=0;
	for(int i=x;i>0;i-=lowbit(i))
	sum+=t[i];
	return sum;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		ans+=query(x);
		update(x);
	}
	if(ans%2)cout<<"Petr";else cout<<"Um_nik";
}


#include<bits/stdc++.h>
#define maxn 1000005
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int t[maxn];
int n;
int x,ans;
struct Edge{
	int Next,To;
}e[maxn];

int First[maxn];
int tot;

int add_edge(int x,int y){
	tot++;
	e[tot].To=y;
	e[tot].Next=First[x];
	First[x]=tot;
}
int low[maxn];
int dfn[maxn];
int visited[maxn];
int vis[maxn];
int Stack[maxn];
int color;
int cnt;
int tail;

int tarjan(int x){
//	cout<<x<<endl;
    low[x]=dfn[x]=++cnt;
    visited[x]=vis[x]=1;
    Stack[++tail]=x;

    for(int i=First[x];i!=-1;i=e[i].Next){
        int y=e[i].To;
        if(!visited[y]){
            tarjan(y);
            low[x]=min(low[x],low[y]);
        }
        else if(vis[y]){
            low[x]=min(low[x],dfn[y]);
        }
    }

    if(low[x]==dfn[x]){
    	color++;
    	while(1){
    		int y=Stack[tail--];
    		vis[y]=0;
    		if(y==x)break;
    	}
    }
}

int main(){
	memset(First,-1,sizeof(First));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		add_edge(x,i);
	}
	for(int i=1;i<=n;i++)if(!visited[i])tarjan(i);
	ans=n-color;
//	cout<<ans;
	if(n%2){
		if(ans%2)cout<<"Petr";else cout<<"Um_nik";
	}
	else{
		if(ans%2==0)cout<<"Petr";else cout<<"Um_nik";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define pc putchar_unlocked
#define gc getchar_unlocked
typedef long long ll;
typedef unsigned long long llu;
#define mp make_pair
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define scstr(x) scanf("%s",x)
#define pd(x) printf("%d",x)
#define pstr(x) printf("%s",x)
#define newl() printf("\n")
#define fl(i,n) for (i=0;i<n;i++)
#define fle(i,n) for (i=1;i<=n;i++)
#define fla(i,a,n) for (i=a;i<n;i++)
#define mem(a,i) memset(a,i,sizeof(a))
#define fi first
#define se second
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii ;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
#define gcd __gcd
#define wl(n) while (n--)
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define tr(container, it)  for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(v) v.begin(),v.end()
#define tatt(cont) typeof(cont.begin())
const double eps = 0.000000000000001 ;
#define MOD 1000000007
typedef long double LF;
typedef double lF;
#define hihihaha ((double)CLOCKS_PER_SEC)
#define nl putchar('\n')
//-------------
int A[1000010];
void atpos(int ind) {
	if (A[ind] == -1) {
		return;
	}
	int x = A[ind];
	A[ind] = -1;
	atpos(x);
}
int main()
{	//ios::sync_with_stdio(0), cin.tie(0);
	int n, i, j;
	sc(n);
	for (i = 1; i <= n; i++) {
		sc(A[i]);
	}
	int cyc = 0;
	for (i = 1; i <= n; i++) {
		if (A[i] != -1) {
			atpos(i);
			cyc++;
		}
	}
	debug(cyc);
	int ans = n - cyc;
	if (!((ans & 1) ^ ((3 * n) & 1))) {
		printf("Petr\n");
	}
	else {
		printf("Um_nik\n");
	}

	return 0;

}

//01010110 01101100 01100001 01100100 00101110


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=40005;
int n,a[N],c[N],ans;
void ready()
{
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
}
inline void msort(int l,int r)
{
  if(l==r)return;
  int mid=(l+r)>>1;
  msort(l,mid);msort(mid+1,r);
  int i=l,j=mid+1,k=l;
  while(i<=mid&&j<=r){
    if(a[i]<=a[j])
      c[k++]=a[i++];
    else{
      c[k++]=a[j++];
      ans+=(mid-i+1);
    }
  }
  while(i<=mid)c[k++]=a[i++];
  while(j<=r)c[k++]=a[j++];
  for(i=l;i<=r;i++)
    a[i]=c[i];
}
void work()
{
  msort(1,n);
}
int main()
{
  std::ios::sync_with_stdio(false);
  ready();work();
  if((3*n-ans)&1){
    puts("Um_nik");
  }
  else
    puts("Petr");

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
        t--;
        if(t==0)
        {
            break;
        }
//        for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
//        cout<<num[i]<<" "<<num[num[i]]<<endl;
        while(num[i]!=i)
        {

            swap(num[i],num[num[i]]);
//            cout<<i<<" "<<num[i]<<endl;
//            i--;
            cnt++;
        }
    }

    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
        t--;
        if(t==0)
        {
            break;
        }
       // for(int i=1;i<=n;i++){
          //  cout<<num[i];
        //}
      //  cout<<endl;
    //    cout<<num[i]<<" "<<num[num[i]]<<endl;
        if(num[i]!=i)
        {
          // cout<<i<<" "<<num[i]<<endl;
            swap(num[i],num[num[i]]);
            i--;
            cnt++;
        }
    }
    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else if((7*n+1-cnt)%2==0) cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
////        t--;
//        if(t==0)
//        {
//            break;
//        }
//        for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
//        cout<<num[i]<<" "<<num[num[i]]<<endl;
        if(num[i]!=i)
        {

            swap(num[i],num[num[i]]);
//            cout<<i<<" "<<num[i]<<endl;
            i--;
            cnt++;
        }
    }
//    for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1000005;
int n,a[N],c[N],ans;
void ready()
{
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
}
inline void msort(int l,int r)
{
  if(l==r)return;
  int mid=(l+r)>>1;
  msort(l,mid);msort(mid+1,r);
  int i=l,j=mid+1,k=l;
  while(i<=mid&&j<=r){
    if(a[i]<=a[j])
      c[k++]=a[i++];
    else{
      c[k++]=a[j++];
      ans+=(mid-i+1);
    }
  }
  while(i<=mid)c[k++]=a[i++];
  while(j<=r)c[k++]=a[j++];
  for(i=l;i<=r;i++)
    a[i]=c[i];
}
void work()
{
  msort(1,n);
}
int main()
{
  std::ios::sync_with_stdio(false);
  ready();work();
  if((3*n-ans)&1){
    puts("Um_nik");
  }
  else
    puts("Petr");

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
        t--;
        if(t==0)
        {
            break;
        }
       // for(int i=1;i<=n;i++){
          //  cout<<num[i];
        //}
      //  cout<<endl;
    //    cout<<num[i]<<" "<<num[num[i]]<<endl;
        if(num[i]!=i)
        {
          // cout<<i<<" "<<num[i]<<endl;
            swap(num[i],num[num[i]]);
            i--;
            cnt++;
        }
    }
    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
        t--;
        if(t==0)
        {
            break;
        }
//        for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
//        cout<<num[i]<<" "<<num[num[i]]<<endl;
        while(num[i]!=i)
        {

            swap(num[i],num[num[i]]);
//            cout<<i<<" "<<num[i]<<endl;
            i--;
            cnt++;
        }
    }

    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else if((7*n+1-cnt)%2==0) cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1000005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    int temp;
    int cnt=0;
    int t=10;
    for(int i=1;i<=n;i++)
    {
////        t--;
//        if(t==0)
//        {
//            break;
//        }
//        for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
//        cout<<num[i]<<" "<<num[num[i]]<<endl;
        while(num[i]!=i)
        {

            swap(num[i],num[num[i]]);
//            cout<<i<<" "<<num[i]<<endl;
//            i--;
            cnt++;
        }
    }
//    for(int i=1;i<=n;i++){
//            cout<<num[i]<<" ";
//        }
//        cout<<endl;
    if((3*n-cnt)%2==0)
    {
        cout<<"Petr"<<endl;
    }
    else cout<<"Um_nik"<<endl;
    //cout<<cnt<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int a[2001000],b[2001000],c[2001000],n,m,i,j,k;

inline int rd(){
    int x=0;
    char c=getchar();
    bool f=false;
    while(!isdigit(c)){
        if(c=='-') f=true;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return f?-x:x;
}

void discretize(){
    sort(b+1,b+1+n);
    unique(b+1,b+1+n)-b-1;
    for(i=1;i<=n;++i) a[i]=lower_bound(b+1,b+1+n,a[i])-b;
}

inline int lowbit(int x){return x&-x;}

int add(int x,int k){
    for(int i=x;i<=n;i+=lowbit(i))c[i]+=k;
}

int sum(int x){
    int ret=0;
    for(int i=x;i>0;i-=lowbit(i)) ret+=c[i];
    return ret;
}

int main(){
    n=rd();
    for(i=1;i<=n;++i) a[i]=b[i]=rd();
    discretize();
    long long ans=0;
    for(i=n;i>0;--i){
        add(a[i],1);
        ans+=sum(a[i]-1);
    }
    if(ans%2==(n*3)%2){
        printf("Petr\n");
    }else
        printf("Um_nik\n");
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
int c[100005],n;
int lowbit(int x)
{
    return x&(-x);
}
void update(int x,int v)
{
    while(x<=n)
    {
        c[x]+=v;
        x+=lowbit(x);
    }
}
int sum(int x)
{
    int ret=0;
    while(x>0)
    {
        ret+=c[x];
        x-=lowbit(x);
    }
    return ret;
}
int main()
{
    scanf("%d",&n);
    int x,ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        update(x,1);
        ans+= i-sum(x);//靠....手抖
    }
    //printf("%d\n",ans);
    if( (ans%2&&(3*n)%2) || (ans%2==0&&(3*n)%2==0) ) printf("Petr\n");
    else  printf("Um_nik\n");
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#define maxn 1000000+2
using namespace std;
int d[maxn],a[maxn];
int n;
int lowbit(int x)
{
    return x&(-x);
}
void upd(int x,int val)
{
    while(x<=n)
    {
        d[x]+=val;
        x+=lowbit(x);
    }
}
int query(int x)
{
    int sum=0;
    while(x)
    {
        sum+=d[x];
        x-=lowbit(x);
    }
    return sum;
}
int main()
{
    while(scanf("%d",&n)!=EOF&&n)
    {
        int i,x;
        memset(d,0,sizeof(d));
        memset(a,0,sizeof(a));
        int ans=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            upd(a[i],1);
            ans+=i-query(a[i]);
        }
        int judge=3*n;
        //printf("[%d]\n",ans);
        if(ans%2==judge%2) printf("Petr\n");
        else printf("Um_nik\n");
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1001000;
ll a[maxn],d[maxn];

ll lowbit(int x)
{
    return x&(-x);
}

void add(int x,int val)
{
    while(x<=maxn)
    {
        d[x]+=val;
        x=x+lowbit(x);
    }
}

ll ask(int x)
{
    long long sum=0;
    while(x>0)
    {
        sum+=d[x];
        x=x-lowbit(x);
    }
    return sum;
}

int main()
{
    int n;
    scanf("%d",&n);
    ll i;
    ll ans=0;
    memset(d,0,sizeof(d));
    for(i=n;i>=1;i--)
    {
        scanf("%d",&a[i]);
        ans=ans+ask(a[i]-1);
        add(a[i],1);
    }
    if(ans==n)
    {
        printf("Petr\n");
    }
    else
        printf("Um_nik\n");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1001000;
ll a[maxn],d[maxn];

ll lowbit(int x)
{
    return x&(-x);
}

void add(int x,int val)
{
    while(x<=maxn)
    {
        d[x]+=val;
        x=x+lowbit(x);
    }
}

ll ask(int x)
{
    long long sum=0;
    while(x>0)
    {
        sum+=d[x];
        x=x-lowbit(x);
    }
    return sum;
}

int main()
{
    int n;
    scanf("%d",&n);
    ll i;
    ll ans=0;
    memset(d,0,sizeof(d));
    /*for(i=n;i;i--)
    {
        ll b;
        scanf("%lld",&b);
        add(b,1);
       ans=ans+i-ask(b);

    }*/
     for(i=n;i>=1;i--)
    {
        scanf("%lld",&a[i]);
        //ans=ans+ask(b-1);
        //add(b,1);
    }
        for(i=n;i;i--)
    {

        ans=ans+ask(a[i]-1);
        add(a[i],1);
    }
   printf("%lld\n",ans);
    if((3*n-ans)==n*2)
    {
        printf("Petr\n");
    }
    else
        printf("Um_nik\n");
    return 0;
}


#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
#define rep(i,s,t) for(int i=s;i<t;++i)
#define INF (0x3f3f3f3f)
using namespace std;
const int N = 1e6+5;
int a[N],t[N],n;
long long ans;
void mg(int l,int m,int r) {
  int i=l,j=m+1,k=0;
  while(i<=m && j<=r) {
    if(a[i]<=a[j]) t[k++]=a[i++];
    else t[k++] = a[j++], ans += m-i+1;
  }
  while(i<=m) t[k++]=a[i++]; while(j<=r) t[k++]=a[j++];
  for(int i=0;i<k;++i) a[l+i]=t[i];
}
void ms(int l,int r) {
  if(l<r) {
    int m = (l+r)>>1;
    ms(l,m);
    ms(m+1,r);
    mg(l,m,r);
  }
}
int main() {
  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%d",a+i);
  ms(0,n-1);
  if((ans&1)== (7*n+1&1) ) cout<<"Um_nik"<<endl;
  else cout<<"Petr"<<endl;
  return 0;
}


#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
#define rep(i,s,t) for(int i=s;i<t;++i)
#define INF (0x3f3f3f3f)
using namespace std;
const int N = 1e6+5;
int a[N],t[N],n;
long long ans;
void mg(int l,int m,int r) {
  int i=l,j=m+1,k=0;
  while(i<m && j<r) {
    if(a[i]<=a[j]) t[k++]=a[i++];
    else t[k++] = a[j++], ans += m-i+1;
  }
  while(i<=m) t[k++]=a[i++]; while(j<=r) t[k++]=a[j++];
  for(int i=0;i<k;++i) a[l+i]=t[i];
}
void ms(int l,int r) {
  if(l<r) {
    int m = (l+r)>>1;
    ms(l,m);
    ms(m+1,r);
    mg(l,m,r);
  }
}
int main() {
  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%d",a+i);
  ms(0,n-1);
  if((ans&1)== (7*n+1&1) ) cout<<"Um_nik"<<endl;
  else cout<<"Petr"<<endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
	int n;
	cin >> n;
	int a[n+5],b[n+5];
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[a[i]]=i;
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i)
		{
			int x=a[i],y=b[i];
			swap(a[i],a[b[i]]);
			b[x]=y;
			cnt++;
		}
	}
	if((3*n-cnt)%2==0)
		cout << "Petr\n";
	else
		cout << "Um_nik\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
	int n;
	cin >> n;
	int a[n+5],b[n+5];
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[a[i]]=i;
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i)
		{
			int x=a[i],y=b[i];
			swap(&a[i],&a[b[i]]);
			b[x]=y;
			cnt++;
		}
	}
	if((3*n-cnt)%2==0)
		cout << "Petr\n";
	else
		cout << "Um_nik\n";
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<memory.h>
#include<map>
using namespace std;

#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define ll long long
#define lowbit(i) i&(-i)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1

const int maxn=1000000+6;
const int mod=1e9+7;
const double eps=1e-6;

int sum[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>sum[i];
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(sum[i]==i) continue;
        while(sum[i]!=i){
            cnt++;
            int t=sum[i];
            swap(sum[i],sum[t]);
        }
    }
    if(cnt&1){
        if((3*n)&1) cout<<"Petr"<<endl;
        else cout<<"Um_nik"<<endl;
    }else {
        if((7*n+1)&1) cout<<"Petr"<<endl;
        else cout<<"Um_nik"<<endl;
    }
    return 0;
}


//应该是逆序数问题
//定理，在一个n级排列中，任意两个元素的位置互换，逆序数总是改变奇数个
//然后注意到3n和7n+1的奇偶性相反
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=1000005;
int a[MAXN];
int merge (int *A, int begin, int mid, int end)
{
        static int count = 0;
        int result[end - begin + 1];
        int i = begin;
        int j = mid + 1;
        int k = 0;
        while (i <= mid && j <= end) {
            if (A[i] <= A[j]) {
                    result[k ++] = A[i ++];
            }
            else {
                count += mid - i + 1;
                result[k ++] = A[j ++];
            }
        }
             while (j <= end)
                 result [k ++] = A[j ++];
            while (i <= mid)
                 result[k ++] = A[i ++];
        for (k = 0; k < end - begin + 1;k ++)
            A[begin + k] = result[k];
            return count;
    }
/*
 * 归并排序中调用merge函数
 */
int mergeSort(int *a, int begin, int end) {
    int sum = 0;
    if (begin < end) {
        int mid = (begin + end)/2;
        mergeSort (a, begin, mid);
        mergeSort (a, mid + 1, end);
        sum = merge (a, begin, mid, end);
    }
    return sum;
}
int main()
{
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=mergeSort(a,0,n-1);//求得的ans就是逆序数
    if(ans%2)//表示逆序数是奇数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Petr\n");
        }
        else
        {
            printf("Alex\n");
        }
    }
    else//表示逆序数是偶数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Alex\n");
        }
        else
        {
            printf("Petr\n");
        }
    }
    return 0;
}


//应该是逆序数问题
//定理，在一个n级排列中，任意两个元素的位置互换，逆序数总是改变奇数个
//然后注意到3n和7n+1的奇偶性相反
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=1000005;
int a[MAXN];
long long merge (int *A, int begin, int mid, int end)
{
        long long count = 0;
        int result[end - begin + 1];
        int i = begin;
        int j = mid + 1;
        int k = 0;
        while (i <= mid && j <= end) {
            if (A[i] <= A[j]) {
                    result[k ++] = A[i ++];
            }
            else {
                count +=(long long)(mid - i + 1);
                result[k ++] = A[j ++];
            }
        }
             while (j <= end)
                 result [k ++] = A[j ++];
            while (i <= mid)
                 result[k ++] = A[i ++];
        for (k = 0; k < end - begin + 1;k ++)
            A[begin + k] = result[k];
            return count;
    }
/*
 * 归并排序中调用merge函数
 */
long long mergeSort(int *a, int begin, int end) {
    long long sum = 0;
    if (begin < end) {
        int mid = (begin + end)/2;
        mergeSort (a, begin, mid);
        mergeSort (a, mid + 1, end);
        sum = merge (a, begin, mid, end);
    }
    return sum;
}
int main()
{
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=mergeSort(a,0,n-1);//求得的ans就是逆序数
    if(ans%2)//表示逆序数是奇数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Petr\n");
        }
        else
        {
            printf("Alex\n");
        }
    }
    else//表示逆序数是偶数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Alex\n");
        }
        else
        {
            printf("Petr\n");
        }
    }
    return 0;
}


//应该是逆序数问题
//定理，在一个n级排列中，任意两个元素的位置互换，逆序数总是改变奇数个
//然后注意到3n和7n+1的奇偶性相反
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=1000005;
int a[MAXN];
int merge (int *A, int begin, int mid, int end)
{
        static int count = 0;
        int result[end - begin + 1];
        int i = begin;
        int j = mid + 1;
        int k = 0;
        while (i <= mid && j <= end) {
            if (A[i] <= A[j]) {
                    result[k ++] = A[i ++];
            }
            else {
                count += mid - i + 1;
                result[k ++] = A[j ++];
            }
        }
             while (j <= end)
                 result [k ++] = A[j ++];
            while (i <= mid)
                 result[k ++] = A[i ++];
        for (k = 0; k < end - begin + 1;k ++)
            A[begin + k] = result[k];
            return count;
    }
/*
 * 归并排序中调用merge函数
 */
int mergeSort(int *a, int begin, int end) {
    int sum = 0;
    if (begin < end) {
        int mid = (begin + end)/2;
        mergeSort (a, begin, mid);
        mergeSort (a, mid + 1, end);
        sum = merge (a, begin, mid, end);
    }
    return sum;
}
int main()
{
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=mergeSort(a,0,n-1);//求得的ans就是逆序数
    if(ans%2)//表示逆序数是奇数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Petr\n");
        }
        else
        {
            printf("Um_nik\n");
        }
    }
    else//表示逆序数是偶数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Alex\n");
        }
        else
        {
            printf("Um_nik\n");
        }
    }
    return 0;
}


//应该是逆序数问题
//定理，在一个n级排列中，任意两个元素的位置互换，逆序数总是改变奇数个
//然后注意到3n和7n+1的奇偶性相反
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=1000005;
int a[MAXN];
int merge (int *A, int begin, int mid, int end)
{
        static int count = 0;
        int result[end - begin + 1];
        int i = begin;
        int j = mid + 1;
        int k = 0;
        while (i <= mid && j <= end) {
            if (A[i] <= A[j]) {
                    result[k ++] = A[i ++];
            }
            else {
                count += mid - i + 1;
                result[k ++] = A[j ++];
            }
        }
             while (j <= end)
                 result [k ++] = A[j ++];
            while (i <= mid)
                 result[k ++] = A[i ++];
        for (k = 0; k < end - begin + 1;k ++)
            A[begin + k] = result[k];
            return count;
    }
/*
 * 归并排序中调用merge函数
 */
int mergeSort(int *a, int begin, int end) {
    int sum = 0;
    if (begin < end) {
        int mid = (begin + end)/2;
        mergeSort (a, begin, mid);
        mergeSort (a, mid + 1, end);
        sum = merge (a, begin, mid, end);
    }
    return sum;
}
int main()
{
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=mergeSort(a,0,n-1);//求得的ans就是逆序数
    if(ans%2)//表示逆序数是奇数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Petr\n");
        }
        else
        {
            printf("Um_nik\n");
        }
    }
    else//表示逆序数是偶数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Um_nik\n");
        }
        else
        {
            printf("Petr\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000000+100;
int n;
int a[maxn];

int main(){
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    int cnt = 0;
    for(int i=1; i<=n; i++)
    {
        if(a[i] == i) continue;
        while(a[i] != i)
        {
            cnt++;
            int t = a[i];
            swap(a[i], a[t]);
        }
    }
    if(n & 1)
    {
        if(cnt & 1) cout<<"Petr"<<endl;
        else cout<<"Um_nik"<<endl;
    }
    else
    {
        if(cnt & 1) cout<<"Um_nik"<<endl;
        else cout<<"Petr"<<endl;
    }
}


//应该是逆序数问题
//定理，在一个n级排列中，任意两个元素的位置互换，逆序数总是改变奇数个
//然后注意到3n和7n+1的奇偶性相反
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=1000005;
int a[MAXN];
int merge (int *A, int begin, int mid, int end) {
        static int count = 0;
        int result[end - begin + 1];
        int i = begin;
        int j = mid + 1;
        int k = 0;
        while (i <= mid && j <= end) {
            if (A[i] <= A[j]) {
                    result[k ++] = A[i ++];
            }
            else {
                count += mid - i + 1;
                result[k ++] = A[j ++];
            }
        }
             while (j <= end)
                 result [k ++] = A[j ++];
            while (i <= mid)
                 result[k ++] = A[i ++];
        for (k = 0; k < end - begin + 1;k ++)
            A[begin + k] = result[k];
            return count;
    }
/*
 * 归并排序中调用merge函数
 */
int mergeSort(int *a, int begin, int end) {
    int sum = 0;
    if (begin < end) {
        int mid = (begin + end)/2;
        mergeSort (a, begin, mid);
        mergeSort (a, mid + 1, end);
        sum = merge (a, begin, mid, end);
    }
    return sum;
}
int main()
{
    memset(a,0,sizeof(a));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=mergeSort(a,0,n-1);//求得的ans就是逆序数
    if(ans%2)//表示逆序数是奇数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Peter\n");
        }
        else
        {
            printf("Alex\n");
        }
    }
    else//表示逆序数是偶数
    {
        if(n%2)//表示n是奇数,Peter的应该是奇数，Alex的是偶数
        {
            printf("Alex\n");
        }
        else
        {
            printf("peter\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=1000005;
int a[maxn],b[maxn];
int main()
{
    int n,cnt=0,t=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
         scanf("%d",&a[i]);
         b[a[i]]=i;         //�±�����;
    }
    while(t<=n)
    {
        if(a[t]!=t){
            int tmp1=a[t],tmp2=t;
            swap(a[t],a[b[t]]);
            swap(b[tmp1],b[tmp2]);
            cnt++;
        }
        t++;
        /*for(int i=1;i<=n;i++)
            cout << a[i] << " ";
        cout << endl;*/
    }
    //cout << cnt << endl;
    if(cnt%3==0)
        printf("Petr\n");
    else
        printf("Um_nik\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=1000005;
int a[maxn],b[maxn];
int main()
{
    int n,cnt=0,t=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
         scanf("%d",&a[i]);
         b[a[i]]=i;         //�±�����;
    }
    while(t<=n)
    {
        if(a[t]!=t){
            int tmp1=a[t],tmp2=t;
            swap(a[t],a[b[t]]);
            swap(b[tmp1],b[tmp2]);
            cnt++;
        }
        t++;
        /*for(int i=1;i<=n;i++)
            cout << a[i] << " ";
        cout << endl;*/
    }
    //cout << cnt << endl;
    if(cnt%2==n%2)
        printf("Petr\n");
    else
        printf("Um_nik\n");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long

struct node
{
    int l;
    int r;
    ll val;
};

node tree[4000010];
ll pre[1000010];
int num[1000010];
int n;

void pushup(int cur)
{
    tree[cur].val=tree[cur*2].val+tree[cur*2+1].val;
    return;
}

ll query(int pl,int pr,int cur)
{
    ll res;
    if(pl<=tree[cur].l&&tree[cur].r<=pr)
    {
        return tree[cur].val;
    }
    res=0;
    if(pl<=tree[cur*2].r) res+=query(pl,pr,cur*2);
    if(pr>=tree[cur*2+1].l) res+=query(pl,pr,cur*2+1);
    return res;
}

void update(int tar,int cur)
{
    if(tree[cur].l==tree[cur].r)
    {
        tree[cur].val=1;
        return;
    }
    if(tar<=tree[cur*2].r) update(tar,cur*2);
    else update(tar,cur*2+1);
    pushup(cur);
    return;
}

void build(int l,int r,int cur)
{
    int m;
    tree[cur].l=l;
    tree[cur].r=r;
    tree[cur].val=0;
    if(l==r) return;
    m=(l+r)/2;
    build(l,m,cur*2);
    build(m+1,r,cur*2+1);
    pushup(cur);
    return;
}

int main()
{
    ll ans;
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
    }
    build(1,n,1);
    for(i=1;i<=n;i++)
    {
        if(num[i]<n)
        {
            pre[i]+=query(num[i]+1,n,1);
        }
        update(num[i],1);
    }
    build(1,n,1);
    for(i=n;i>=1;i--)
    {
        if(num[i]>1)
        {
            pre[i]+=query(1,num[i]-1,1);
        }
        update(num[i],1);
    }
    ans=0;
    for(i=1;i<=n;i++)
    {
        ans+=pre[i];
    }
    ans/=2;
    if(ans%2==(3*n)%2) printf("Petr\n");
    else printf("Um_nik\n");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006];
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
                j=a[i];
        }

    }
    if(3*n-(n-cnt))
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006]={0};
int a[1000006];
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
            {
                vis[j]=1;
                j=a[j];
            }
        }

    }
    if(!(cnt&1))
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006]={0};
int a[1000006];
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
            {
                vis[j]=1;
                j=a[i];
            }
        }

    }
    if(3*n-(n-cnt))
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006]={0};
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
            {
                vis[j]=1;
                j=a[i];
            }
        }

    }
    if(3*n-(n-cnt))
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006]={0};
int a[1000006];
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
            {
                vis[j]=1;
                j=a[i];
            }
        }

    }
    if((3*n-(n-cnt))%2==0)
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<stack>
#include<utility>//pair
#include<functional>//greater
#include<queue>
#include<set>
#include<map>
#include<string.h>
#include<algorithm>
#include<math.h>
#define F first
#define S second
#define sd(n) scanf("%d",&n)
#define sdd(m,n) scanf("%d %d",&m,&n)
#define sl(n) scanf("%I64d",&n)
#define sll(m,n) scanf("%I64d %I64d",&m,&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",n)
#define pd(n) printf("%d\n",n)
#define pl(n) printf("%I64d\n",n)
#define pc(n) printf("%c ",n)
#define ps(n) printf("%s ",n)
#define NL printf("\n")
#define pb(n) push_back(n)
#define sz size()
#define clr(v,a,b) for(int i=a;i<=b;i++)v[i].clear()
#define all(v) v.begin(),v.end()
#define mod 1000000007//10^9+7
#define pp(a,b) make_pair(a,b)
/*#include<fstream>
ifstream fin("in.txt");
ofstream fout("out.txt");*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pll;
int dxx[8]={0,1,1,1,0,-1,-1,-1};
int dyy[8]={1,1,0,-1,-1,-1,0,1};
bool vis[1000006]={0};
int a[1000006];
int main()
{

    //freopen("inp.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int n;
    sd(n);
    for(int i=1;i<=n;i++)
        sd(a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            int j=i;
            while(!vis[j])
            {
                vis[j]=1;
                j=a[i];
            }
        }

    }
    if(!(cnt&1))
        printf("Petr");
    else
        printf("Um_nik");
    return 0;
}


/**
    freopen("in.in", "r", stdin);
    freopen("my.out", "w", stdout);
*/
#include <cstdio>
#include <algorithm>
const int N = 1000010;

int a[N], pos[N];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        pos[a[i]] = i;
    }
    int tot = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] == i) {
            continue;
        }
        else {
            tot++;
            int p = pos[i];
            std::swap(a[i], a[p]);
            pos[a[p]] = p;
        }
    }

    tot &= 1;
    n &= 1;
    if(tot ^ n) {
        printf("Um_nik");
    }
    else {
        printf("Petr");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[1000005];

int main () {
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d" ,&a[i]);
    int cnt=0;
    for(int i=0;i<n;i++) {
        while(a[i]!=i) {
            cnt++;
            int t=a[i];
            swap(a[i], a[t]);
        }
    }

    if(n&1) {
        if(cnt&1) puts("Petr");
        else puts("Um_nik");
    } else {
        if(cnt&1) puts("Um_nik");
        else puts("Petr");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[100005];

int main () {
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d" ,&a[i]);
    int cnt=0;
    for(int i=0;i<n;i++) {
        while(a[i]!=i) {
            cnt++;
            int t=a[i];
            swap(a[i], a[t]);
        }
    }

    if(n&1) {
        if(cnt&1) puts("Petr");
        else puts("Um_nik");
    } else {
        if(cnt&1) puts("Um_nik");
        else puts("Petr");
    }
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;
const int maxn=1000000+10;

int a[maxn],v[maxn],ans;

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

    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    int ans=n;
    for(int i=1;i<=n;i++)
    if(!v[i])
    {
        ans--;
        v[i]=1;
        for(int x=a[i];x!=i;x=a[x]) v[x]=1;
    }
    if(ans&1) printf("Petr\n");
    else printf("Um_nik\n");
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;
const int maxn=1000000+10;

int a[maxn],v[maxn],ans;

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

    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    int ans=n;
    for(int i=1;i<=n;i++)
    if(!v[i])
    {
        ans--;
        v[i]=1;
        for(int x=a[i];x!=i;x=a[x]) v[x]=1;
    }
    if((ans&1)==(n&1)) printf("Petr\n");
    else printf("Um_nik\n");
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;
const int maxn=1000000+10;

int a[maxn],v[maxn],ans;

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

    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    int ans=n;
    for(int i=1;i<=n;i++)
    if(!v[i])
    {
        ans--;
        for(int x=a[i];x!=i;x=a[x]) v[x]=1;
    }
    if(ans&1) printf("Petr\n");
    else printf("Um_nik\n");
    return 0;
}