import java.util.Scanner; public class Main { private static final int INF = Integer.MAX_VALUE; public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int m = input.nextInt(); int start = input.nextInt(); int end = input.nextInt(); int[][] edge = new int[n + 1][n + 1]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) edge[i][j] = INF; while (m-- > 0) { int a = input.nextInt(); int b = input.nextInt(); edge[a][b] = 1; edge[b][a] = 1; } for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (edge[i][k] != INF && edge[k][j] != INF) edge[i][j] = Math.min(edge[i][j], edge[i][k] + edge[k][j]); System.out.println(edge[start][end]); input.close(); } }