There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of.

Input

Each of the three lines of the input contains two integers. The i-th line contains integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th point. It is guaranteed that all points are distinct.

Output

Print a single number — the minimum possible number of segments of the polyline.

Examples

Input

1 -1
1 1
1 2


Output

1


Input

-1 -1
-1 3
4 3


Output

2


Input

1 1
2 3
3 2


Output

3

Note

The variant of the polyline in the first sample: <image> The variant of the polyline in the second sample: <image> The variant of the polyline in the third sample: <image>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class ProblemD2 {
    BufferedReader rd;

    ProblemD2() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] b = intarr();
        int[] c = intarr();
        NavigableMap<Integer, Integer> xs = new TreeMap<>();
        NavigableMap<Integer, Integer> ys = new TreeMap<>();
        int[][] pts = new int[][] { a, b, c };
        for(int[] u: pts) {
            inc(xs, u[0]);
            inc(ys, u[1]);
        }
        int res;
        if(xs.size() == 1 || ys.size() == 1) {
            res = 1;
        } else if(xs.size() == 2) {
            res = c(pts, xs, 0);
        } else if(ys.size() == 2) {
            res = c(pts, ys, 1);
        } else {
            res = 3;
        }
        out(res);
    }

    private int c(int[][] pts, NavigableMap<Integer, Integer> xs, int k) {
        Iterator<Map.Entry<Integer, Integer>> it = xs.entrySet().iterator();
        Map.Entry<Integer, Integer> f1 = it.next();
        if(f1.getValue() == 2) {
            f1 = it.next();
        }
        int p = 0;
        int[] yd = new int[2];
        int yMid = 0;
        for(int[] u: pts) {
            if(f1.getKey().equals(u[k])) {
                yMid = u[1-k];
            } else {
                yd[p++] = u[1-k];
            }
        }
        Arrays.sort(yd);
        int res;
        if(yMid <= yd[0] || yMid >= yd[1]) {
            res = 2;
        } else {
            res = 3;
        }
        return res;
    }

    private void inc(NavigableMap<Integer, Integer> s, int k) {
        Integer cur = s.get(k);
        if(cur == null) {
            s.put(k, 1);
        } else {
            s.put(k, cur + 1);
        }
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    public String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemD2();
    }
}