// Arup Guha
// 4/11/2023
// Solution to 2017 MAPS Problem B: Colouring Book

import java.util.*;

public class colouringbook {

	public static int n;
	public static int numE;
	public static ArrayList<Integer>[] g;
	public static line[] segs;
	public static int[][] pList;
	public static pt2D[] pts;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		numE = stdin.nextInt();
		
		// Read in points.
		pts = new pt2D[n];
		for (int i=0; i<n; i++) {
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			pts[i] = new pt2D(x, y);
		}
		
		// Form graph and segments.
		g = new ArrayList[n];
		for (int i=0; i<n; i++) g[i] = new ArrayList<Integer>();
		segs = new line[numE];
		pList = new int[numE][2];
		for (int i=0; i<numE; i++) {
			int u = stdin.nextInt(); pList[i][0] = u;
			int v = stdin.nextInt(); pList[i][1] = v;
			g[u].add(v);
			g[v].add(u);
			segs[i] = new line(pts[u], pts[v]);
		}
		
		int res = -1;
	
		// Pt on segment case.
		if (ptOnSeg()) res = -1; 
		
		// Not connected.
		else if (notConnected()) res = -1; 
		
		// Two segments cross.
		else if (cross()) res = -1; 
		
		// Euler's formula.
		else res = numE - n + 2;
		
		// Ta da!
		System.out.println(res);
	}
	
	// Returns true iff not connected.
	public static boolean notConnected() {
		
		// Vacuously connected.
		if (n == 1) return false;
		
		// Definitely not connected since n > 1 to get here.
		if (g[0].size() == 0) return true;
		
		// Set up BFS.
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.offer(0);
		boolean[] used = new boolean[n];
		used[0] = true;
		
		// Run BFS.
		while (q.size() > 0) {
			int cur = q.poll();
			
			for (Integer x: g[cur]) {
				if (used[x]) continue;
				used[x] = true;
				q.offer(x);
			}
		}
		
		// Not connected if something isn't reached.
		for (int i=0; i<n; i++)
			if (!used[i])
				return true;
			
		// Connected if we get here.
		return false;
	}
	
	// Returns true if a point is on a segment.
	public static boolean ptOnSeg() {
	
		// Loop through segments and points.
		for (int i=0; i<numE; i++) {
			for (int j=0; j<n; j++) {
				
				// Skip this...
				if (j == pList[i][0] || j == pList[i][1]) continue;
				
				// Get both angles.
				line tmp = new line(pts[pList[i][0]], pts[j]);
				double a1 = Math.atan2(segs[i].dir.y,segs[i].dir.x); 
				double a2 = Math.atan2(tmp.dir.y,tmp.dir.x);
				
				// Not an issue if the angles are different.
				if (Math.abs(a1-a2) > 1e-9) continue;
				
				// If the tmp vector is shorter, we have an issue.
				if (tmp.dir.mag()-1e-9 < segs[i].dir.mag()) return true;
			}
		}
		
		// Never found a point on a segment.
		return false;
	}
	
	// Returns true iff two segments cross.
	public static boolean cross() {
		
		// Go through each pair of segments.
		for (int i=0; i<numE; i++) {
			for (int j=0; j<numE; j++) {
				if (i == j) continue;
				
				// Oops a pair intersects (in the middle).
				if (segs[i].intersect(segs[j])) return true;
			}
		}
		
		// No intersections if we get here.
		return false;
	}
}

class vect2D {

    public double x;
    public double y;

    public vect2D(double myx, double myy) {
        x = myx;
        y = myy;
    }

    public vect2D(pt2D start, pt2D end) {
        x = end.x - start.x;
        y = end.y - start.y;
    }

    public double dot(vect2D other) {
        return this.x*other.x + this.y*other.y;
    }

    public double mag() {
        return Math.sqrt(x*x+y*y);
    }

    // Thjs formula comes from using the relationship between the dot product and
    // the cosine of the included angle.
    public double angle(vect2D other) {
        return Math.acos(this.dot(other)/mag()/other.mag());
    }

    public double signedCrossMag(vect2D other) {
        return this.x*other.y-other.x*this.y;
    }

    public double crossMag(vect2D other) {
        return Math.abs(signedCrossMag(other));
    }
}

class line {

    final public static double EPSILON = 1e-9;

    public pt2D p;
    public vect2D dir;

    public line(pt2D start, pt2D end) {
        p = start;
        dir = new vect2D(start, end);
    }

	// Returns true iff these two segments intersect "in the middle" of one of the segments.
    public boolean intersect(line other) {

        // This is the denominator we get when setting up our system of equations for
        // our two parametric line parameters.
        double den = det(dir.x, -other.dir.x, dir.y, -other.dir.y);
        if (Math.abs(den) < EPSILON) return false;

        // We already have the denominator, now solve for the numerator for lambda, the
        // parameter for this line. Then return the resultant point.
        double numLambda = det(other.p.x-p.x, -other.dir.x, other.p.y-p.y, -other.dir.y);
        double lambda = numLambda/den;
		
		// Other parameter.
		double numBeta = det(dir.x, other.p.x-p.x, dir.y, other.p.y-p.y);
		double beta = numBeta/den;
		
		// Both have to be in the middle...
		boolean c1 = false, c2 = false;
		if (lambda > EPSILON && lambda < 1-EPSILON) c1 = true;
		if (beta > EPSILON && beta < 1-EPSILON) c2 = true;
		return c1 && c2;
    }

    public static double det(double a, double b, double c, double d) {
        return a*d - b*c;
    }
}

class pt2D {

    public double x;
    public double y;

    public pt2D(double myx, double myy) {
        x = myx;
        y = myy;
    }
}