import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); int s = Integer.parseInt(sa[2]) - 1; int t = Integer.parseInt(sa[3]) - 1; sa = br.readLine().split(" "); int[] p = new int[n]; for (int i = 0; i < n; i++) { p[i] = Integer.parseInt(sa[i]); } List> list = new ArrayList<>(n); for (int i = 0; i < n; i++) { list.add(new ArrayList<>()); } for (int i = 0; i < m; i++) { sa = br.readLine().split(" "); int a = Integer.parseInt(sa[0]) - 1; int b = Integer.parseInt(sa[1]) - 1; list.get(a).add(b); list.get(b).add(a); } br.close(); int[] d = new int[list.size()]; PriorityQueue que = new PriorityQueue(); Node first = new Node(s, 0, p[s]); que.add(first); while (!que.isEmpty()) { Node cur = que.poll(); if (cur.d < d[cur.v]) { continue; } for (int next : list.get(cur.v)) { int alt = d[cur.v]; if (cur.x > p[next]) { alt++; } if (alt > d[next]) { d[next] = alt; que.add(new Node(next, alt, Math.min(cur.x, p[next]))); } } } System.out.println(d[t]); } static class Node implements Comparable { int v, d, x; public Node(int v, int d, int x) { this.v = v; this.d = d; this.x = x; } public int compareTo(Node o) { if (d != o.d) { return o.d - d; } return o.x - x; } } }