import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class E {
	public static void main(String[] args) {
		MyScanner scan = new MyScanner();
		int N = scan.nextInt()-1;
		String s1 = scan.nextLine();
		String sTemp = scan.nextLine();
		if(N==1){
			if((s1.charAt(0)=='N'&&sTemp.charAt(0)=='S')||(s1.charAt(0)=='S'&&sTemp.charAt(0)=='N')){
				System.out.println("NO");
			}else if((s1.charAt(0)=='W'&&sTemp.charAt(0)=='E')||(s1.charAt(0)=='E'&&sTemp.charAt(0)=='W')){
				System.out.println("NO");
			}
			else{
				System.out.println("YES");
			}
			return;
		}

		String card = "EWSN";
		StringBuilder s2 = new StringBuilder("");
		for(int i=N-1;i>=0;i--){
			s2.append(card.charAt(card.indexOf(sTemp.charAt(i))^1));
		}

		int[] count = new int[N];
		int j=0, i=0;
		while(i<N){
			if(s2.charAt(j)!=s1.charAt(i)){
				if(j==0)i++;
				else{
					j=count[j-1];
				}
			}else{
				count[i]=(i==0)?1:count[i-1]+1;
				i++;j++;
			}
		}
		System.out.println((count[N-1]==0)?"YES":"NO");
	}
	private static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public MyScanner() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }

	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }

	    String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	     }
	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	 }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author George Marcus
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        String dirs = "NEWS";

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.readInt();
            N--;
            String PA = in.readString();
//        PA = "." + PA;
            char[] A = PA.toCharArray();
            String PB = in.readString();
//        PB = "." + PB;
            char[] B = PB.toCharArray();

            int crti = 0;
            int crtj = 0;
            while (crti < N || crtj < N) {
                int pi = crti;
                int pj = crtj;

                while (pi < N) {
                    if (pj < N && A[pi] == B[pj]) {
                        pj++;
                    }
                    if (pj > 0 && A[pi] == op(B[pj - 1])) {
                        pj--;
                    }
                    pi++;
                }

                while (pj < N) {
                    if (pi < N && A[pi] == B[pj]) {
                        pi++;
                    }
                    if (pi > 0 && A[pi - 1] == op(B[pj])) {
                        pi--;
                    }
                    pj++;
                }

                if (pi <= crti) {
                    out.println("NO");
                    return;
                }
                crti = pi;
                crtj = pj;
            }

            out.println("YES");
        }

        private char op(char c) {
            return dirs.charAt(3 - dirs.indexOf(c));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c))
                    res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;

public class C214 {
    int n;
    boolean room[][];
    boolean dep[][];
    int num[];
    int idx[];
    boolean visited[];
    int ans = Integer.MAX_VALUE;
    Set<Integer> zeros;
    static int [][] pay;
    static {
        pay = new int[3][3];
        for( int i =0; i<3 ; i ++){
            pay[i][i] = 0;
            pay[i][(i+1)%3] = 1;
            pay[i][(i+2)%3] = 2;
        }
    }

    public void solve(Scanner cin , PrintWriter cout ){
        n = cin.nextInt();
        room = new boolean[3][n];
        dep = new boolean[n][n];
        num = new int[n];
        idx = new int[n];
        visited = new boolean[n];
        for( int i=0 ;i <n ; i ++){
            idx[i] = cin.nextInt()-1;
            room[idx[i]][i] = true;
        }

        zeros = new HashSet<Integer>();
        for( int i= 0;i <n ; i ++){
            int k = cin.nextInt();
            num[i] = k;
            if( k ==0) {
                zeros.add(i);
            }
            for( int j=0;j <k ; j ++){
                int pre = cin.nextInt() - 1;
                dep[pre][i] = true;
            }
        }
        for( int r = 0; r < 3 ; r ++) {
            search(r,0);
        }
        cout.println(ans);
    }

    private void search(int r,int cost){
        if( cost >= ans)
            return;
        if( zeros.size() == 0 ){
            if( cost < ans ) {
                ans = cost;
            }
            return;
        }
        Queue<Integer> zs = new LinkedBlockingQueue<Integer>();
        for( int zero : zeros){
            if( idx[zero] == r) {
                zs.add(zero);
            }
        }
        if( zs.isEmpty()) {
            return ;
        }
        Set<Integer> bak_zeros = new HashSet<Integer>();
        Set<Integer> add_zeros = new HashSet<Integer>();
        int [] bak_num = new int[n];
        for( int i=0;i<n;i++){
            bak_num [i] = num[i];
        }
        while(!zs.isEmpty()) {
            int now = zs.poll();
            zeros.remove(now);
            bak_zeros.add(now);
            cost ++ ;
            visited[now] = true;
            for( int i=0 ;i < n ; i ++) {
                if( !visited[i] && dep[now][i]  ) {
                    num[i] -- ;
                    if( num[i] == 0) {
                        if( idx[i] == r ) {
                            zs.add(i);
                        } else{
                            zeros.add(i);
                            add_zeros.add(i);
                        }
                    }
                }
            }
        }
        if( zeros.size() == 0 ){
            if( cost < ans ) {
                ans = cost;
            }
//          System.out.println(cost);
        } else {
            for( int i=0; i<3 ; i ++){
                if( i != r ) {
                    search(i,cost + pay[r][i]);
                }
            }
        }
        for( int zero : bak_zeros){
            zeros.add(zero);
            visited[zero] = false;
        }
        for( int zero : add_zeros){
            zeros.remove(zero);
        }
        for( int i=0; i<n ; i ++){
            num[i] = bak_num[i];
        }
    }

    public static void main (String [] args){
        C214 solution = new C214();
        Scanner cin = new Scanner(System.in);
        PrintWriter cout = new PrintWriter(System.out);
        solution.solve(cin, cout);
        cin.close();
        cout.close();
    }
}


import java.util.*;
import java.io.*;

public class Main {

	BufferedReader in;
	StringTokenizer str = null;

	private String next() throws Exception {
		if (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}
	int n;
	int [][]c;
	int []a;
	Set<Integer>[]g;
	List<Integer> nofather;

	public void run() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("input.txt"));
		n = nextInt();
		c = new int[3][3];
		c[0] = new int[]{0, 1 ,2};
		c[1] = new int[]{2, 0, 1};
		c[2] = new int[]{1 ,2, 0};

		a = new int[n];
		for(int i=0;i<n;i++) a[i] = nextInt()-1;
		g = new HashSet[n];
		for(int i=0;i<n;i++){
			g[i] = new HashSet<Integer>();
		}

		nofather = new ArrayList<Integer>();
		for(int i=0;i<n;i++){
			int m = nextInt();
			for(int j=0;j<m;j++){
				int x = nextInt()-1;
				g[x].add(i);
			}
			if (m == 0){
				nofather.add(i);
			}
		}

		List<int[]> b = new ArrayList<int[]>();
		for(int i : nofather){
			b.add(solve(i));
		}

		int m = b.size();
		int ret = Integer.MAX_VALUE;
		for(int i=0;i<m;i++){
			ret = Math.min(ret, go(i, b));
		}
		int val = 0;
		for(int[] l : b)
			val+=l[2];
		System.out.println(ret + val);
	}

	private int go(int s, List<int[]> b){
		int m = b.size();
		boolean used[] = new boolean[m];
		int cur[] = b.get(s);
		used[s] = true;
		int ret = 0;
		while(true){
			int min = Integer.MAX_VALUE/2;
			int idx = -1;
			int index = -1;
			for(int i=0;i<m;i++){
				if (!used[i]){
					int l[] = b.get(i);
					int cost = c[a[cur[1]]][a[l[0]]];
					if (min > cost){
						min = cost;
						index = i;
						idx = l[1];
					}else if (cost == min){
						if (idx > l[1]){
							index = i;
							idx = l[1];
						}
					}
				}
			}
			if (index == -1)
				return ret;
			ret+=min;
			cur = b.get(index);
			used[index] = true;
		}
	}

	private int[] solve(int s){

		int d[] = new int[n];
		Arrays.fill(d, Integer.MAX_VALUE/2);
		d[s] = 0;
		boolean used[] = new boolean[n];
		used[s] = true;
		int cur = s;
		while(true){
			for(int i : g[cur]){
				if (d[i] > d[cur] + c[a[cur]][a[i]]){
					d[i] = d[cur] + c[a[cur]][a[i]];
				}
			}
			int min = Integer.MAX_VALUE/2;
			int index = -1;
			for(int i=0;i<n;i++){
				if (!used[i] && min > d[i]){
					min = d[i];
					index = i;
				}
			}
			if (index == -1) break;
			used[index] = true;
			cur = index;
		}
		int max = d[s];
		int index = s;
		int val = 0;
		for(int i=0;i<n;i++){
			if (d[i] != Integer.MAX_VALUE/2){
				val++;
				if (max < d[i]){
					max = d[i];
					index = i;
				}
			}
		}
		return new int[]{s, index, max + val};
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}
}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Serjio
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		int n = in.nextInt(), pk[] = new int[n], ans = Integer.MAX_VALUE;
		boolean used[] = new boolean[n];
		List<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < n; ++i)
			pk[i] = in.nextInt() - 1;
		for (int i = 0; i < n; ++i) {
			int k = in.nextInt();
			g[i] = new ArrayList<Integer>();
			for (int j = 0; j < k; ++j)
				g[i].add(in.nextInt() - 1);
			Collections.sort(g[i]);
		}
		for (int i = 0; i < 3; ++i) {
			Arrays.fill(used, false);
			int s = 0;
			int p = i;
			int cnt = 0;
			while (true) {
				if (cnt == n) {
					ans = Math.min(ans, s);
					break;
				}
				for (int j = 0; j < n; ++j) {
					if (pk[j] == p && !used[j]) {
						boolean f = true;
						for (Integer k : g[j])
							if (!used[k])
								f = false;
						if (true) {
							used[j] = true;
							cnt++;
							s++;
						}
					}
				}
				if (cnt == n) {
					ans = Math.min(ans, s);
					break;
				}
				s++;
				p = (p + 1) % 3;
			}
		}
		out.print(ans);
	}
}

class FastScanner {
    public BufferedReader br;
    public StringTokenizer tokenizer;

    public FastScanner(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next()  {
        while (tokenizer == null || !tokenizer.hasMoreTokens()){
            try {
                tokenizer = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Serjio
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		int n = in.nextInt(), pk[] = new int[n];
		long ans = Long.MAX_VALUE;
		boolean used[] = new boolean[n];
		List<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < n; ++i)
			pk[i] = in.nextInt() - 1;
		for (int i = 0; i < n; ++i) {
			int k = in.nextInt();
			g[i] = new ArrayList<Integer>();
			for (int j = 0; j < k; ++j)
				g[i].add(in.nextInt() - 1);
		}
		for (int i = 0; i < 3; ++i) {
			Arrays.fill(used, false);
			long s = n;
			int p = i;
			int cnt = 0;
			while (true) {
				for (int j = 0; j < n; ++j) {
					if (pk[j] == p && !used[j]) {
						boolean f = true;
						for (Integer k : g[j])
								f &= used[k];
						if (f) {
							used[j] = true;
							cnt++;
						}
					}
				}
				for (int j = 0; j < n; ++j) {
					if (pk[j] == p && !used[j]) {
						boolean f = true;
						for (Integer k : g[j])
							f &= used[k];
						if (f) {
							used[j] = true;
							cnt++;
						}
					}
				}
				if (cnt == n)
					break;
				s++;
				p = (p + 1) % 3;
			}
			ans = Math.min(ans,s);
		}
		out.print(ans);
	}
}

class FastScanner {
    public BufferedReader br;
    public StringTokenizer tokenizer;

    public FastScanner(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next()  {
        while (tokenizer == null || !tokenizer.hasMoreTokens()){
            try {
                tokenizer = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }


import java.util.Scanner;

public class OlimpB {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int y = scan.nextInt();
		int y2 = scan.nextInt();
		System.out.println(6 - y - y2);
	}


import java.io.*;
public class MyClass {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    System.out.println(6 - (a+b));
  }
}


import java.lang.Math;

public class A
{
      static int a = Math.random() * 3 + 1;
      static int b = Math.random() * 3 + 1;
      public static void main(String[] args)
      {
       if(a == 2 && b == 3 && a != b || a == 3 && b == 2 && a != b)
       {
             System.out.println(1);
       }
       else if(a == 1 && b == 3 && a != b || a == 3 && b == 1 && a != b)
       {
             System.out.println(2);
       }
       else if(a == 1 && b == 2 && a != b || a == 2 && b == 1 && a != b)
       {
             System.out.println(3);
       }
      }
}


import java.io.*;
public class A
{
public static void main(String[] args)
{
BufferedReader br = new BufferedReader(new InputStreamReder(System.in));
try
{
 String n = br.readLine();
 if(!n.startsWith(n.substring(1,2)))
 {
 if(n.substring(0,1).equals(2) && n.substring(1,2).equals(3) || n.substring(0,1).equals(3) && n.subdtring(1,2).equals(2))

   System.out.println(1);
 }
 else if(n.substring(0,1).equals(1) && n.substring(1,2).equals(3) || n.substring(0,1).equals(3) && n.substring(0,1).equals(1))
 {
       System.out.println(2);
 }
 else if(n.substring(0,1).equals(2) && n.substring(1,2).equals(1) || n.substring(0,1).equals(1) && n.substring(1,2).equals(2))
 {
       System.out.println(3);
 }

}
catch(Exception excp)
{

}
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C {

    public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static StringTokenizer tok;

    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public static String nextToken() throws IOException {
        if (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException {
        int n = nextInt();
        int m = nextInt();
        List<Set<Integer>> graph = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            graph.add(new HashSet<>());
        }
        for (int i = 0; i < m; i++) {
            int u = nextInt() - 1;
            int v = nextInt() - 1;
            graph.get(u).add(v);
            graph.get(v).add(u);
        }
        List<Set<Integer>> reverse = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            reverse.add(new HashSet<>());
            for (int j = 0; j < n; j++) {
                if (i != j && !graph.get(i).contains(j)) {
                    reverse.get(i).add(j);
                }
            }
        }
        ArrayList<Character> line = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            line.add(null);
        }
        Queue<Integer> queue = new LinkedList<>();
        int counter = 0;
        while (counter < n) {
            if (line.get(counter) == null && !reverse.get(counter).isEmpty()) {
                queue.add(counter);
                while (!queue.isEmpty()) {
                    int x = queue.remove();
                    if (line.get(x) == null) {
                        line.set(x, 'a');
                    }
                    char other = line.get(x) == 'a' ? 'c' : 'a';
                    for (int near: reverse.get(x)) {
                        if (line.get(near) == null) {
                            line.set(near, other);
                            queue.add(near);
                        } else if (line.get(x) == line.get(near)) {
                            System.out.println("No");
                            return;
                        }
                    }
                }
            }
            counter++;
        }
        for (int i = 0; i < n; i++) {
            if (line.get(i) == null) {
                line.set(i, 'b');
            }
        }
        System.out.println("Yes");
        for (int i = 0; i < n; i++) {
            System.out.print(line.get(i));
        }
    }
}


package x0001_aim_tech_round_div_1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class A_GraphAndString {
	public static final int A = 1, B = 2, C = 3, NOT_MARKED = 0;

	private final boolean isDebug;

	int n, m;
	boolean[][] g;
	int[] v;
	public A_GraphAndString(boolean isDebug) {
		this.isDebug = isDebug;
	}

	public void readInput() {
		Scanner sc = null;
		if (isDebug) {
			try {
				sc = new Scanner(new FileInputStream("src\\x0001_aim_tech_round_div_1\\A_input1.txt"));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			sc =  new Scanner(System.in);
		}

		n = sc.nextInt();
		m = sc.nextInt();
		if (isDebug)
			System.out.format("n=%d m=%d%n", n, m);

		g = new boolean[n][n];
		for (int i = 0; i < m; i++) {
			int u = sc.nextInt() - 1;
			int v = sc.nextInt() - 1;
			if (isDebug)
				System.out.format("%d %d%n", u + 1, v + 1);
			g[u][v] = true;
		}

		v = new int[n];
	}

	public void solve() {
		if (m == 0) {
			switch (n) {
			case 1:
				System.out.println("Yes");
				System.out.print("a");
				break;
			case 2:
				System.out.println("Yes");
				System.out.print("ac");
				break;
			default:
				System.out.println("No");
				break;
			}

			return;
		}

		mark();
	}

	private void mark() {
		findAndMarkAllB();
		if (!findAndMarkAllA())
			return;
		if (!findAndMarkAllC())
			return;

		if (isGraphLegit()) {
			System.out.println("Yes");
			for (int i = 0; i < n; i++) {
				String letter;
				switch (v[i]) {
				case A: letter = "a"; break;
				case B: letter = "b"; break;
				case C: letter = "c"; break;
				default:
					throw new AssertionError();
				}
				System.out.print(letter);
			}
		} else {
			System.out.println("No");
		}
	}

	private void findAndMarkAllB() {
		for (int y = 0; y < n; y++) {
			boolean isB = true;
			for (int x = 0; x < n; x++) {
				if (y != x && !connected(y, x)) {
					isB = false;
					break;
				}
			}

			if (isB) {
				v[y] = B;
			}
		}
	}

	private boolean findAndMarkAllA() {
		int idxA = -1;
		for (int i = 0; i < n; i++) {
			if (v[i] == NOT_MARKED) {
				idxA = i;
				break;
			}
		}

		if (idxA == -1) {	// All B
			System.out.println("Yes");
			for (int i = 0; i < n; i++) {
				System.out.print("b");
			}

			return false;
		}

		v[idxA] = A;
		for (int i = idxA + 1; i < n; i++) {
			if (connected(idxA, i) && v[i] == NOT_MARKED) {
				v[i] = A;
			}
		}

		return true;
	}

	private boolean findAndMarkAllC() {
		int idxC = -1;
		for (int i = 0; i < n; i++) {
			if (v[i] == NOT_MARKED) {
				idxC = i;
				break;
			}
		}

		if (idxC == -1) {	// No C
			if (isGraphLegit()) {
				System.out.println("Yes");
				for (int i = 0; i < n; i++) {
					String letter = v[i] == B ? "b" : "a";
					System.out.print(letter);
				}
			} else {
				System.out.println("No");
			}

			return false;
		}

		v[idxC] = C;
		for (int i = idxC + 1; i < n; i++) {
			if (v[i] == NOT_MARKED) {
				if (connected(idxC, i)) {
					v[i] = C;
				} else {
					System.out.println("No");
					return false;
				}
			}
		}

		return true;
	}

	private boolean isGraphLegit() {
		for (int i = 0; i < n; i++) {
			if (v[i] == A || v[i] == C) {
				int letter = v[i] == A ? C : A;
				for (int j = 0; j < n; j++) {
					if (i != j) {
						if ((v[j] != letter && !connected(i, j))
								|| (v[j] == letter && connected(i, j))) {
							return false;
						}
					}
				}
			}
		}

		return true;
	}

	private boolean connected(int u, int v) {
		return g[u][v] || g[v][u];
	}

	public static void main(String[] args) {
		A_GraphAndString solver = new A_GraphAndString(false);
		solver.readInput();
		solver.solve();
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        private static int[] cntComops;
        private static boolean[] markComps;
        private static boolean[][] matrix;
        private static int ch;
        private static char[] result;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();
            ch = 0;
            result = new char[n];
            List<List<Integer>> g = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                g.add(new ArrayList<>());
            }
            matrix = new boolean[n][n];

            for (int i = 0; i < m; i++) {
                int v = in.nextInt() - 1;
                int u = in.nextInt() - 1;
                g.get(v).add(u);
                g.get(u).add(v);
                matrix[v][u] = true;
                matrix[u][v] = true;
            }
            cntComops = new int[n];
            int compLabel = 0;
            List<List<Integer>> comps = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (cntComops[i] == 0) {
                    List<Integer> subGraph = new ArrayList<>();
                    Set<Integer> subset = new HashSet<>();
                    subGraph.add(i);
                    subset.add(i);
                    cntComops[i]++;
                    int it = 0;
                    while (it < subGraph.size()) {
                        int cur = subGraph.get(it++);
                        for (int j = 0; j < g.get(cur).size(); j++) {
                            int to = g.get(cur).get(j);
                            if (!subset.contains(to)) {
                                Set<Integer> toSubset = new HashSet<>(g.get(to));
                                if (toSubset.containsAll(subGraph)) {
                                    subGraph.add(to);
                                    subset.add(to);
                                    cntComops[to]++;
                                }
                            }
                        }
                    }
                    compLabel++;
                    comps.add(subGraph);
                }
            }

            for (int i = 0; i < n; i++) {
                if (cntComops[i] > 2) {
                    out.print("No");
                    return;
                }
            }
            for (int i = 0; i < comps.size(); i++) {
                for (int j = i + 1; j < comps.size(); j++) {
                    for (int x : comps.get(i)) {
                        for (int y : comps.get(j)) {
                            if (x != y && matrix[x][y] && cntComops[x] == 1 && cntComops[y] == 1) {
                                out.print("No");
                                return;
                            }
                        }
                    }
                }
            }
            markComps = new boolean[comps.size()];
            for (int i = 0; i < comps.size(); i++) {
                if (!markComps[i] && isStart(comps.get(i))) {
                    dfs(i, comps);
                }
            }
            if (ch > 4) {
                out.println("No");
                return;
            }
            out.println("Yes");
            for (int i = 0; i < n; i++) {
                out.print(result[i]);
            }

        }

        private static boolean isStart(List<Integer> comp) {
            for (int i = 0; i < comp.size(); i++) {
                if (cntComops[comp.get(i)] == 1) {
                    return true;
                }
            }
            return false;
        }

        private static void dfs(int id, List<List<Integer>> g) {
            markComps[id] = true;
            char cur = (char) (ch + 'a');
            char next = (char) (ch + 1 + 'a');
            for (int i = 0; i < g.size(); i++) {
                if (!markComps[i] && isBro(g.get(id), g.get(i))) {
                    for (int x : g.get(id)) {
                        boolean isX = true;
                        for (int y : g.get(i)) {
                            if (x == y) {
                                isX = false;
                                break;
                            }
                        }
                        if (result[x] == 0) {
                            if (isX) {
                                result[x] = cur;
                            } else {
                                result[x] = next;
                            }
                        }
                    }
                    ch += 2;
                    dfs(i, g);
                    return;
                }
            }
            for (int x : g.get(id)) {
                if (result[x] == 0) {
                    result[x] = cur;
                }
            }
            ch += 2;
        }

        private static boolean isBro(List<Integer> a, List<Integer> b) {
            for (Integer x : a) {
                for (Integer y : b) {
                    if (matrix[x][y]) {
                        return true;
                    }
                }
            }
            return false;
        }

    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner(InputStream io) {
            br = new BufferedReader(new InputStreamReader(io));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


// import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

/**
 * Created by hama_du on 2016/02/08.
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();
        int[][] graph = new int[n][n];
        for (int i = 0; i < m ; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            graph[a][b] = graph[b][a] = 1;
        }
        String ans = solve(graph);
        if (ans == null) {
            out.println("No");
        } else {
            out.println("Yes");
            out.println(ans);
        }
        out.flush();
    }

    static String solve(int[][] graph) {
        int n = graph.length;
        List<Integer>[] cog = new List[n];
        for (int i = 0 ; i < n ; i++) {
            cog[i] = new ArrayList<>();
        }
        for (int i = 0 ; i < n ; i++) {
            for (int j = i+1 ; j < n ; j++) {
                if (graph[i][j] == 0) {
                    cog[i].add(j);
                    cog[j].add(i);
                }
            }
        }

        int[] color = new int[n];
        for (int i = 0 ; i < n ; i++) {
            if (color[i] != 0) {
                continue;
            }
            if (cog[i].size() == 0) {
                continue;
            }
            if (!dfs(i, 1, cog, color)) {
                return null;
            }
        }

        for (int i = 0 ; i < n ; i++) {
            for (int j = 0; j < n ; j++) {
                if (color[i] == 1 && color[j] == -1 && graph[i][j] == 1) {
                    return null;
                }
            }
        }
        char[] abc = {'c','b','a'};
        StringBuilder line = new StringBuilder();
        for (int i = 0 ; i < n ; i++) {
            line.append(abc[color[i]+1]);
        }
        return line.toString();
    }

    private static boolean dfs(int now, int col, List<Integer>[] cog, int[] color) {
        if (color[now] != 0) {
            return color[now] == col;
        }
        color[now] = col;
        for (int to : cog[now]) {
            if (!dfs(to, -col, cog, color)) {
                return false;
            }
        }
        return true;
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public void solve() {
        Scan sn = new Scan();
        long n;
        n = sn.nextLong();
        long temp = (long)Math.sqrt(n);
        for(long i=temp ;i>=1;i--)
        {
            long te = i*i;
            long num = n;
            int count =0;
            String s = String.valueOf(num);
            for(int j=s.length()-1;j>=0;j--){
                long t = te%10;
                if(s.charAt(j)-'0'==t){
                    count++;
                    te = te/10;
                }
            }
            if(count==String.valueOf(i*i).length()){
                System.out.println(String.valueOf(n).length()-count);
/*
                System.out.println(i);
*/
                return;
            }
        }
        System.out.println(-1);
    }

    public static void main(String[] args) {
        Main solver = new Main();
        solver.solve();
    }

    class Scan {
        BufferedReader br;
        StringTokenizer st;

        public Scan() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
close


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public void solve() {
        Scan sn = new Scan();
        long n;
        n = sn.nextLong();
        long temp = (long)Math.sqrt(n);
        for(long i=temp ;i>=1;i--)
        {
            long te = i*i;
            long num = n;
            int count =0;
            String s = String.valueOf(num);
            for(int j=s.length()-1;j>=0;j--){
                long t = te%10;
                if(s.charAt(j)-'0'==t){
                    count++;
                    te = te/10;
                }
            }
            if(count==String.valueOf(i*i).length()){
                System.out.println(String.valueOf(n).length()-count);
/*
                System.out.println(i);
*/
                return;
            }
        }
        System.out.println(-1);
    }

    public static void main(String[] args) {
        C962 solver = new C962();
        solver.solve();
    }

    class Scan {
        BufferedReader br;
        StringTokenizer st;

        public Scan() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.lang.Integer;
public class HelloWorld{

     public static void main(String []args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = n + "";
        int ans = 20;
        for(int i = 1; i < (1<<s.length()); i++) {
            String temp = "";
            int count = s.length();
            for(int j = 0; j < s.length(); j++) {
                if(((1<<j) & i) > 0) {
                    temp += s.charAt(j);
                    count--;
                }
            }
            int num = Integer.parseInt(temp);
            double sqrt = Math.sqrt(num);
            double diff = sqrt - (int)sqrt;
            if(diff < 1e-15) {
                ans = ans < count ? ans : count;
                //System.out.println(num + " " + count);
            }
            ..System.out.println(temp);

        }
        System.out.println(ans != 20 ? ans : -1);
     }
}


import java.io.*;
import java.util.*;

public class Main {

	public static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32765);
			tokenizer = null;
		}

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32765);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public Integer[] nextIntegerArr(int n) {
			Integer[] arr = new Integer[n];
			for (int i = 0; i < n; i++) {
				arr[i] = new Integer(this.nextInt());
			}
			return arr;
		}

		public int[][] next2DIntArr(int n, int m) {
			int[][] arr = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					arr[i][j] = this.nextInt();
				}
			}
			return arr;
		}

		public int[] nextSortedIntArr(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			Arrays.sort(arr);
			return arr;
		}

		public long[] nextLongArr(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

		public long[] nextSortedLongArr(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			Arrays.sort(arr);
			return arr;
		}

		public char[] nextCharArr(int n) {
			char[] arr = new char[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextChar();
			}
			return arr;
		}
	}

	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		// InputStream inputStream = System.in; // Useful when taking input other than
		// console eg file handling // check ctor of inputReader
		// To print in file use this:- out = new PrintWriter("destination of file")
		// including extension");

		String str = scn.next();
		long rv = func(str, 0, Integer.parseInt(str), 0, new HashSet<>());

		if (rv > 20) {
			System.out.println(-1);
		} else {
			System.out.println(rv);
		}
	}

	public static long func(String str, int i, int num, int op, HashSet<Integer> list) {
		if(num == -1) {
			return Integer.MAX_VALUE;
		}
		int k = (int) Math.sqrt(num);
		if (k * k == num) {
			return op;
		}
		if (str.length() == i) {
			return Integer.MAX_VALUE;
		}

		long rv = Integer.MAX_VALUE;

		int kk = 0;
		String s = "";
		for (int x = 0; x < str.length(); x++) {
			if (!list.contains(x) && x != i) {
				s = s + str.charAt(x);
			}
		}
		if(s.length() != 0) {
			kk = Integer.parseInt(s);
		} else {
			kk = -1;
		}

		if (i < str.length() - 1 && str.charAt(i + 1) == '0') {
			rv = func(str, i + 1, num, op, list);
		} else {
			long x = func(str, i + 1, num, op, list);
			list.add(i);
			long y = func(str, i + 1, kk, op + 1, list);
			list.remove(i);
			rv = Math.min(x, y);
		}

		return rv;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

    public static void main(String arg[]) throws IOException
    {

        boolean leap[]=new boolean[2039];

        for(int i=1900;i<=2038;i++)
        {
            if((i%4==0&&i%100!=0))
            {

            leap[i]=true;

            }

        }

        leap[2000]=true;
        int d[]=new int[13];
       d[1]=d[3]=d[5]=d[7]=d[12]=d[10]=d[8]=31;
       d[4]=d[6]=d[9]=d[11]=30;
       d[2]=28;

 //   BufferedReader r=new BufferedReader(new FileReader("testcase.txt"));
   BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

   String s=r.readLine();
   s=s.replaceAll(":", " ");
   StringTokenizer str=new StringTokenizer(s);

int y1=Integer.parseInt(str.nextToken());
int m1=Integer.parseInt(str.nextToken());
int d1=Integer.parseInt(str.nextToken());
s=r.readLine();
   s=s.replaceAll(":", " ");

str=new StringTokenizer(s);
int y2=Integer.parseInt(str.nextToken());
int m2=Integer.parseInt(str.nextToken());
int d2=Integer.parseInt(str.nextToken());

if(y1>y2||(y1==y2&&m1>m2)||(y1==y2&&m1==m2&&d1>d2))
{
   int t=y2;
    y2=y1;
    y1=t;
    t=m2;
    m2=m1;
    m1=t;
    t=d2;
    d2=d1;
    d1=t;
}

int days=0;
for(int i=y1+1;i<y2;i++)
{

    if(leap[i])
    {
        days=days+366;
    }
    else
        days=days+365;

}

for(int i=m1+1;i<=12;i++)
{
    days+=d[i];
}

for(int i=1;i<m2;i++)
{
    days=days+d[i];
}

if(m1<=2&&leap[y1])
{
    days++;

}
if(m2>2&&leap[y2])
{
    days++;
}
days=days+d[m1]-d1;
days=days+d2;
System.out.println(days);

}
    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

    public static void main(String arg[]) throws IOException
    {

        boolean leap[]=new boolean[2039];

        for(int i=1900;i<=2038;i++)
        {
            if((i%4==0&&i%100!=0))
            {

            leap[i]=true;

            }

        }

        leap[2000]=true;
        int d[]=new int[13];
       d[1]=d[3]=d[5]=d[7]=d[12]=d[10]=d[8]=31;
       d[4]=d[6]=d[9]=d[11]=30;
       d[2]=28;

 //   BufferedReader r=new BufferedReader(new FileReader("testcase.txt"));
   BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

   String s=r.readLine();
   s=s.replaceAll(":", " ");
   StringTokenizer str=new StringTokenizer(s);

int y1=Integer.parseInt(str.nextToken());
int m1=Integer.parseInt(str.nextToken());
int d1=Integer.parseInt(str.nextToken());
s=r.readLine();
   s=s.replaceAll(":", " ");

str=new StringTokenizer(s);
int y2=Integer.parseInt(str.nextToken());
int m2=Integer.parseInt(str.nextToken());
int d2=Integer.parseInt(str.nextToken());

if(y1>y2||m1>m2||d1>d2)
{
   int t=y2;
    y2=y1;
    y1=t;
    t=m2;
    m2=m1;
    m1=t;
    t=d2;
    d2=d1;
    d1=t;
}

int days=0;
for(int i=y1+1;i<y2;i++)
{

    if(leap[i])
    {
        days=days+366;
    }
    else
        days=days+365;

}

for(int i=m1+1;i<=12;i++)
{
    days+=d[i];
}

for(int i=1;i<m2;i++)
{
    days=days+d[i];
}

if(m1<=2&&leap[y1])
{
    days++;

}
if(m2>2&&leap[y2])
{
    days++;
}
days=days+d[m1]-d1;
days=days+d2;
System.out.println(days);

}
    }


import java.io.*;
import java.util.*;
import java.text.*;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        String d1 = in.nextLine();
        String d2 = in.nextLine();
        SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd");
        Date date1 = null;
        Date date2 = null;
        try {
            date1 = format.parse(d2);
            date2 = format.parse(d1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long difference = Math.round((double)date1.getTime()/ 24/60/60/1000 - (double)date2.getTime()/ 24/60/60/1000);
        long days = difference ;
        out.println(Math.abs(days));

        in.close();
        out.close();
    }


import java.io.*;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Evgeny Savinov
 */
public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        InputStream inputStream = System.in;//new FileInputStream("input.txt");
        OutputStream outputStream = System.out;//new FileOutputStream("output.txt");//
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskE {

    public void solve(int testNumber, InputReader in, PrintWriter out)
    {
        SimpleDateFormat z = new SimpleDateFormat("yyyy:MM:dd");
        z.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
        Date a = null, b = null;
        try {
            a = z.parse(in.next());
        } catch (ParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        try {
            b = z.parse(in.next());
        } catch (ParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        long diff = Math.abs(a.getTime() + b.getTime());
        out.println(diff / 1000 / 3600 / 24);

    }
}

class InputReader
{
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
}


import java.util.*;

public class RoadToPostOffice {
	public static void main(String[] args) {
		Scanner kbd = new Scanner(System.in);
		long finalDit; //final distance computed
		long d = kbd.nextLong(); //distance from home to p.o.
		long k = kbd.nextLong(); //initial distance before breaking
		long a = kbd.nextLong(); //time he spends to drive 1km
		long b = kbd.nextLong(); //time he spends to walk 1km on foot
		long t = kbd.nextLong(); //time he spends to repair his car

		if(d <= k){
			System.out.println(a * d);
		}else{
			if(k * b <= k * a + t){
				long withCar = Math.min(d, k);
				System.out.println(a * withCar + b * (d - WithCar));
			}else{
				long carCount = d/k;
				long ans = a * carCount * k + Math.max(carCount - 1, 0) * t;
				d -= carCount * k;
				if(d * b <= d * a + t){
					ans += d * b;
				}else{
					ans += t + d * a;
					System.out.println(ans);
				}
			}
		}
	}
}


import java.util.*;

public class RoadToPostOffice {
	public static void main(String[] args) {
		Scanner kbd = new Scanner(System.in);
		long finalDit; //final distance computed
		long d = kbd.nextLong(); //distance from home to p.o.
		long k = kbd.nextLong(); //initial distance before breaking
		long a = kbd.nextLong(); //time he spends to drive 1km
		long b = kbd.nextLong(); //time he spends to walk 1km on foot
		long t = kbd.nextLong(); //time he spends to repair his car

		if(d <= k){
			System.out.println(a * d);
		}else{
			if(k * b <= k * a + t){
				long withCar = Math.min(d, k);
				System.out.println(a * withCar + b * (d - WithCar));
			}else{
				long carCount = d/k;
				long ans = a * carCount * k + Math.max(carCount - 1, 0) * t;
				d -= carCount * k;
				if(d * b <= d * a + t){
					ans += d * b;
				}else{
					ans += t + d * a;
					System.out.println(ans);
				}
			}
		}
}


    import java.io.*;
    import java.util.*;
    public class Test{
        public static void main(String [] args) throws IOException{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringTokenizer st = new StringTokenizer(br.readLine());
            long d = Long.parseLong(st.nextToken());
            long k = Long.parseLong(st.nextToken());
            long a = Long.parseLong(st.nextToken());
            long b = Long.parseLong(st.nextToken());
            long t = Long.parseLong(st.nextToken());
            d-=k;
            long ans = k*a;
            if(k*a+t>=k*b){System.out.println(ans+d*b);}
            else{
                ans += (k*a+t)*(d/k);
                long mod = d%k;
                ans += Math.min(mod*a+t, mod*b);
                System.out.println(ans);
            }
        }
    }


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D {

	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long d = sc.nextLong();
		long k = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), t = sc.nextInt();

		if(k * b <= k * a + t)
		{
			long withCar = Math.min(d, k);
			out.println(a * withCar + b * (d - withCar));
		}
		else
		{
			long carCount = d / k;
			long ans = a * carCount * k + Math.max(carCount - 1, 0) * t;
			d -= carCount * k;
			if(d * b <= d * a + t)
				ans += d * b;
			else
				ans += t + d * a;
			out.println(ans);
		}
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(FileReader r){	br = new BufferedReader(r);}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}

	}
}


import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;

public class Problem {

	int INF = -1000 * 1000 * 1000 - 100;
	int counter;
	int[] arr;
	int[] t;

	void solve() throws IOException {
		int n = rI();
		int curChar = 0;
		ArrayList<Character> ansList = new ArrayList<>();
		if(n==0){
			ansList.add('z')
		}
		while(n>0){
			ansList.add((char)('a'+curChar));
			int x = 1;
			int sum = 1 ;
			while(n-sum>=0){
				x++;
				ansList.add((char)('a'+curChar));
				sum += x;
			}
			sum-=x;
			n -= sum;
			curChar++;
		}
		for(char a: ansList){
			out.print(a);
		}
	}

	long get(int r) {
		long sum = 0;
		for (int i = r; i >= 1; i = (i & (i + 1)) - 1) {
			sum += t[i];
		}
		return sum;
	}

	void init() {
		for (int i = 1; i < arr.length; ++i) {
			inc(i, arr[i]);
		}
	}

	void inc(int i, int delta) {
		for (; i < arr.length; i = i | (i + 1)) {
			t[i] += delta;
		}
	}

	public static void main(String[] args) throws IOException {

		new Problem().run();
	}

	boolean isLower(char a) {
		return ((int) a) >= 97 ? true : false;
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;
	Random rnd = new Random();
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	Problem() throws FileNotFoundException {

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
		tok = new StringTokenizer("");
	}

	long checkBit(long mask, int bit) {
		return (mask >> bit) & 1;
	}

	// ======================================================

	// ======================================================
	void run() throws IOException {
		solve();
		out.close();
	}

	char[] reverseCharArray(char[] arr) {
		char[] ans = new char[arr.length];
		for (int i = 0; i < arr.length; ++i) {
			ans[i] = arr[arr.length - i - 1];
		}
		return ans;
	}

	int sqrt(double m) {
		int l = 0;
		int r = 1000000000 + 9;
		int i = 1000;
		while (r - l > 1) {
			int mid = (r + l) / 2;
			if (mid * mid > m) {
				r = mid;
			} else {
				l = mid;
			}
		}
		return l;
	}

	int countPow(int m, int n) {
		int ans = 0;
		while (m % n == 0 && m > 0) {
			ans++;
			m /= n;
		}
		return ans;
	}

	long binPow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b % 2 == 1) {
			return a * binPow(a, b - 1);
		} else {
			long c = binPow(a, b / 2);
			return c * c;
		}

	}

	int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long pow(long x, long k) {
		long ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= x;
		}
		return ans;
	}

	// ////////////////////////////////////////////////////////////////////

	String delimiter = " ";

	String readLine() throws IOException {
		return in.readLine();
	}

	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}

	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}

	double rD() throws IOException {
		return Double.parseDouble(rS());
	}

	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int[] readSortedIntArray(int size) throws IOException {
		Integer[] array = new Integer[size];

		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}

	int[] sortedIntArray(int size, int[] array) throws IOException {
		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}
}


import java.io.*;
import java.util.StringTokenizer;

public class R431C {

    FastScanner sc;
    PrintWriter out;

    int needMinCost;

    String getStringWithCostX(int x) {
        if(x == 0) {
            return "a";
        }

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < 26; i++) {
            if (x == 0) { break; }

            int cur = 0;
            double tmp = cur * (cur + 1) / 2;

            while ( tmp / 2 <= x) {
                cur++;
            }

            x -= tmp;

            char c = (char)('a' + i);
            for (int z = 0; z < cur; z++) {
                sb.append(c);
            }

        }

        return sb.toString();
    }

    public void solve()  {
        needMinCost = sc.nextInt();
        System.out.println(getStringWithCostX(needMinCost));
        /*for (int i=0; i<26; i++) {
            int cnt = 1;

            while ((cnt+1) * cnt/2 <= needMinCost) {
                cnt++;
            }

            needMinCost -= cnt*(cnt-1)/2;

            for (int j=0; j<cnt; j++) {
                System.out.printf("%c", 'a' + i);
            }
        }*/

    }

    private void run() {
        //sc = new FastScanner(new File("input.txt"));
        sc = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.close();
    }

    public static void main(String[] args) {
        new R431C().run();
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

public final class round_431_c
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();

	static int t(int n)
	{
		return (n*(n+1))/2;
	}

	static char[] go(int val1,int val2,int val3)
	{
		char[] res=new char[val1+val2+val3+3];

		int ptr=0;

		for(int i=0;i<=val1;i++)
		{
			res[ptr++]='a';
		}

		for(int j=0;j<=val2;j++)
		{
			res[ptr++]='b';
		}

		for(int k=0;k<=val3;k++)
		{
			res[ptr++]='c';
		}

		return res;
	}

    public static void main(String args[]) throws Exception
    {
		int cost=sc.nextInt();

		if(cost==0)
		{
			out.println("a");
		}

		else
		{
			int val1=0,val2=0,val3=0;

			for(int i=0;i<=500;i++)
			{
				for(int j=0;j<=500;j++)
				{
					for(int k=0;k<=500;k++)
					{
						if(t(i)+t(j)+t(k)==cost)
						{
							val1=i;val2=j;val3=k;
						}
					}
				}
			}

			//System.out.println(val1+" "+val2+" "+val3);

			out.println(new String(go(val1,val2,val3)));
		}

		out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

	public String next() throws Exception {
		return nextToken().toString();
	}

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by Katushka on 11.03.2020.
 */
public class FromY2Y {
    static int[] readArray(int size, InputReader in) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    public static void main(String[] args) throws FileNotFoundException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = in.nextInt();
        long trian = 1;
        long i = 1;
        while (trian * 26 < n || n - (trian - 1) * (n / trian) > 26) {
            i++;
            trian = i * (i + 1) / 2;
        }
        if (n == 0) {
            out.println('a');
        } else if (trian == 1) {
            StringBuilder str = new StringBuilder();
            for (char ch = 'a'; ch < 'a' + n; ch++) {
                str.append(ch).append(ch);
            }
            out.println(str.toString());
        } else {
            long t = (n / trian);
            long k = n - (trian - 1) * (n / trian);
            StringBuilder str = new StringBuilder();
            for (int j = 0; j < i + 1; j++) {
                for (char ch = 'a'; ch < 'a' + (j < 2 ? k : t); ch++) {
                    str.append(ch);
                }
            }
            out.println(str.toString());
        }

        out.close();
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BThreeLevelLaser solver = new BThreeLevelLaser();
        solver.solve(1, in, out);
        out.close();
    }

    static class BThreeLevelLaser {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int U = in.nextInt();
            double[] E = in.nextDoubleArray(n);

            double ans = -1;
            for (int i = 0; i < n; i++) {
                int j = i + 1;
                int l = i + 1;
                int r = n;
                while (r - l > 1) {
                    int mid = (l + r) / 2;
                    if ((E[mid] - E[i]) <= U) {
                        l = mid;
                    } else {
                        r = mid;
                    }
                }
                int k = l;
                if (k != i + 1) {
                    ans = Math.max(ans, (E[k] - E[j]) / (E[k] - E[i]));
                }
            }
            if (ans == -1) out.println(-1);
            else out.println(ans);

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public double[] nextDoubleArray(int size) {
            double[] array = new double[size];
            for (int i = 0; i < size; i++)
                array[i] = nextDouble();
            return array;
        }

    }
}


package vanilla;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
    static class Solver {
        void solve(Scanner in, PrintWriter out) {

            int n = in.nextInt();

            ArrayList<Integer> piles = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                piles.add(in.nextInt());
            }

            Collections.sort(piles);

            if (piles.get(0).equals(piles.get(n/2))) {
                out.println("Bob");
            } else {
                out.println("Alice");
            }

        }
    }
}


import java.io.FileInputStream;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class TaskE {
    int n;
    int[] as;
    public void solve() throws Exception{
        //Scanner sc = new Scanner(System.in);
        Scanner sc = new Scanner(new FileInputStream("inputs/e.in"));
        n = sc.nextInt();
        as = new int[n];
        Map<Integer, Integer> mp = new HashMap<>();
        int m = 1000;
        for(int i=0; i<n; i++){
            as[i] = sc.nextInt();
            if(!mp.containsKey(as[i])) mp.put(as[i], 0);
            mp.put(as[i], mp.get(as[i])+1);
            m = min(m, as[i]);
        }
        if(mp.get(m) > n/2) System.out.println("Bob");
        else System.out.println("Alice");

    }
    public static void main(String[] args) throws Exception {
        TaskE s = new TaskE();
        s.solve();
    }
}


package vanilla;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
}

class Solver {
    void solve(Scanner in, PrintWriter out) {

        int n = in.nextInt();

        ArrayList<Integer> piles = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            piles.add(in.nextInt());
        }

        Collections.sort(piles);

        if (piles.get(0).equals(piles.get(n/2))) {
            out.println("Bob");
        } else {
            out.println("Alice");
        }

    }
}


import java.util.*;
import java.util.stream.*;
public class A {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt;

    int higherSquareRootOfNumber = Math.floor(Math.sqrt(n)) + 1;

    int higherSquareNumber = higherSquareRootOfNumber * higherSquareRootOfNumber;
    int result = higherSquareNumber - n <= higherSquareRootOfNumber
      ? higherSquareRootOfNumber * 2
      : higherSquareRootOfNumber * 2 - 1;

    System.out.println(result);
  }
}


import java.io.*;
import java.util.*;
import javafx.util.Pair;

public class Main
{
    public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int det = (int) Math.sqrt(n);
        int sqr1 = (int) Math.pow(det ,2);
        int sqr2 = (int) Math.pow(det + 1 ,2);
        int range = (sqr2 - sqr1)/2;

        int ans = 0;
        if(n == sqr1) ans = det * 2;
        else if(n > sqr1 + range) ans = det * 2 + 2;
        else ans = det * 2 + 1);
        System.out.println(ans);
	}
}


import java.util.*;
import java.lang.Math;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class mainClass {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int max = 1;
        for (int i=2; i<=Math.sqrt(n); i++) {
            if (n % i == 0) {
                max = i;
            }
        }
        System.out.println(max+n/max);


import static java.lang.Math.ceil;
import static java.lang.Math.sqrt;
import java.util.*;
public class Main{
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int m;
        m=(int) ceil(sqrt(n)*2);
        System.out.println(m)
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    static int max=0;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        StringBuilder sb=new StringBuilder(sc.next());
        dfs(sb,0);
        System.out.println(max);
    }
    static void dfs(StringBuilder s,int m){
        if(s.length()==1)return;
        char c='a';
        int index=-1;
        for(int i=0;i<s.length();i++){
            if(i+1<s.length() && s.charAt(i)-1==s.charAt(i+1) && s.charAt(i)>c){
                index=i;
                c=s.charAt(i);
            }
            if(i-1>=0 && s.charAt(i)-1==s.charAt(i-1) && s.charAt(i)>c){
                index=i;
                c=s.charAt(i);
            }
        }

        if (m + 1 > max) max = m + 1;
        StringBuilder temp = new StringBuilder(s.toString());
        dfs(temp.replace(index, index + 1, ""), m + 1);

        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


inport java.util.*;
public class Solution {

    public static void count(String input) {
        StringBuilder sb = new StringBuilder();
        sb.append(input);

        int i = 0;
        int del = 0;

        while(i < sb.length()) {
            char current = sb.charAt(i);

            if(i+1 < sb.length() && sb.charAt(i+1) == current-1) {
                sb.deleteCharAt(i);del++;
            }
            else if(i+1 < sb.length() && sb.charAt(i+1) == current+1) {
                int j = i+1;
                char next = sb.charAt(j);

                while(j < sb.length() &&  current+1 == next) {
                    next = sb.charAt(j);
                    j = j+1;
                    current = next;
                }
                sb.delete(i+1, j);
                del += j-(i+1);
            }
            else {
                i++;
            }
        }

        return del;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int len = s.nextInt();
        String input = s.nextLine();

        count(input);
    }
}


import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int Size = sc.nextInt();
        sc.nextLine();
        int FuckYouWhyDidYouFuckingGiveMeOne=0;
        if(Size==1){
          System.out.println(FuckYouWhyDidYouFuckingGiveMeOne);
        }
        return;
        String line = sc.nextLine();
        int biggestChar = 'a';
        for (int i = 0; i < line.length(); i++) {
            char currentChar = line.charAt(i);
            if(currentChar > biggestChar){
                biggestChar = currentChar;
            }
        }
        int FucksGiven = 0;
        for (int i = biggestChar; i > 'a' ; i--) {
            for (int j = 0; j < line.length(); j++) {
                if(line.charAt(j) == i){
                    if(j == 0){
                        if(line.charAt(1) == i-1){
                            line = line.substring(j+1);
                            j--;
                            FucksGiven++;
                        }
                    }
                    else if(j == line.length()-1){
                        if(line.charAt(j-1) == i-1){
                            line = line.substring(0,j);
                            j-=2;
                            FucksGiven++;
                        }
                    }
                        else if(line.charAt(j-1) == i-1 || line.charAt(j+1) == i-1 ){
                            line = line.substring(0,j)+line.substring(j+1);
                            j-=2;
                            FucksGiven++;
                        }

                }
            }
        }
        System.out.println(FucksGiven);

    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRemoveAdjacent solver = new CRemoveAdjacent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRemoveAdjacent {
        char[] arr;
        long dp;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            arr = new char[n + 10];
            Arrays.fill(arr, '-');

            dp = new long[n + 10][n + 10][30][30];

            for (int i = 0; i < n + 10; i++) {
                for (int j = 0; j < n + 10; j++) {
                    for (long a[] : dp[i][j]) Arrays.fill(a, -1);
                }
            }
            for (int i = 1; i <= n; i++) arr[i] = in.scanChar();
            long ans = -1;
            ans = Math.max(ans, findIT(1, n, '-', '-'));
            out.print(ans);

        }

        long findIT(int l, int r, char pre, char next) {
            if (l > r) return 0;

            if (pre == '-') pre = 'a' + 28;
            if (next == '-') next = 'a' + 28;

            if (dp[l][r][pre - 'a'][next - 'a'] != -1) return dp[l][r][pre - 'a'][next - 'a'];

            long ans = findIT(l + 1, r, arr[l], next);

            ans = Math.max(ans, findIT(l, r - 1, pre, arr[r]));

            if (arr[l] == (pre + 1)) {
                ans = Math.max(ans, 1 + findIT(l + 1, r, pre, next));
            }

            if (arr[r] == (next + 1)) {
                ans = Math.max(ans, 1 + findIT(l, r - 1, pre, next));
            }

            for (int i = l; i <= r; i++) {
                if (i - 1 >= l && (arr[i - 1] + 1) == arr[i]) {
                    if (i + 1 <= r)
                        ans = Math.max(ans, 1 + findIT(i + 1, r, arr[i - 1], next) + findIT(l, i - 1, pre, arr[i + 1]));
                    else
                        ans = Math.max(ans, 1 + findIT(i + 1, r, arr[i - 1], next) + findIT(l, i - 1, pre, next));
                }
                if (i + 1 <= r && (arr[i + 1] + 1) == arr[i]) {

                    if (i - 1 >= l)
                        ans = Math.max(ans, 1 + findIT(i + 1, r, arr[i - 1], next) + findIT(l, i - 1, pre, arr[i + 1]));
                    else
                        ans = Math.max(ans, 1 + findIT(i + 1, r, pre, next) + findIT(l, i - 1, pre, arr[i + 1]));
                }
            }
            return dp[l][r][pre - 'a'][next - 'a'] = ans;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public char scanChar() {
            int c = scan();
            while (isWhiteSpace(c)) c = scan();
            return (char) c;
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.*;
import java.util.*;
public class BB{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
        final int max = 10000;
          class ship{
            long F , S , T ; int I;
            ship(long b, long c, long d, int a){F = b; S = c; T = d; I = a;}
          }
          class base{
            long F, S;
            base(long a, long b){F = a; S = b;}
          }
          ArrayList<ship> ship[];
          ArrayList<base> base[];
          TreeSet<base> qbase[];
           public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt() , m = in.nextInt();
            make(n , m , in);
            int s = in.nextInt() , b = in.nextInt(), k =in.nextInt();
            long C[] = new long[s + 1];
            ship = new ArrayList[n + 1];
            base = new ArrayList[n + 1];
            qbase = new TreeSet[n + 1];

            for(int i = 0; i <= n; i++){
                ship[i] = new ArrayList<>();
                base[i] = new ArrayList<>();
                qbase[i] = new TreeSet<>((A , B) -> A.F == B.F ? Long.compare(B.S , A.S) : Long.compare(A.F , B.F));
            }

            for(int i = 0; i < s;i ++){
                ship[in.nextInt()].add(new ship(in.nextInt() , in.nextInt(),C[i + 1] = in.nextInt(), i + 1));
            }

            for(int i = 0; i < b;i ++){
                base[in.nextInt()].add(new base(in.nextInt() , in.nextInt()));
            }

            for(int i = 0; i <= n; i++){
                Collections.sort(ship[i] , (A , B) -> Long.compare(A.S , B.S));
            }
            for(int i = 0; i <=n; i++){
                Collections.sort(base[i] , (A , B) -> A.F == B.F ? Long.compare(B.S , A.S) : Long.compare(A.F , B.F));
                int sz = base[i].size();
                long max = 0;
                for(int j = 0; j < sz; j++){
                    base p = base[i].get(j);
                    p.S = Math.max(max , p.S);
                    max = p.S;
                    qbase[i].add(p);
                }
            }
            boolean visit[] = new boolean[n + 1];
            int d[] = new int[n + 1];
            long ans[] = new long[s + 1];
            Arrays.fill(ans, -1);
            ArrayDeque<Integer> ad = new ArrayDeque<>();
            for(int i = 1; i <= n; i++){
                int sz = ship[i].size();
                if(sz == 0) continue;
                int p = 0;
                Arrays.fill(visit , false); Arrays.fill(d , max); ad.clear();
                visit[i] = true; d[i] = 0; ad.add(i);
                o : while(!ad.isEmpty() && p < sz){
                    int u = ad.pollFirst();
                    // System.out.println(u);
                    ship pship = ship[i].get(p);
                    while(d[u] > pship.S && p < sz){
                        ++p;
                        if(p == sz) break o;
                        pship = ship[i].get(p);
                    }
                    int szb = base[u].size();
                    for(int j = p; j < sz && szb > 0; j++){
                        pship = ship[i].get(j);
                        base P = qbase[u].floor(new base(pship.F, 0));
                        if(P == null)continue;
                        // System.out.println(i + " " + pship.I + " " + u + " " + P.S);
                        ans[pship.I] = Math.max(ans[pship.I] ,P.S);
                    }
                    for(int v : ja[u]){
                        if(visit[v])continue;
                        d[v] = d[u] + 1; visit[v] = true;
                        ad.addLast(v);
                    }
                }
            }

            boolean can[] = new boolean[s + 1];
            for(int i = 1; i <= s; i++)can[i] = ans[i] != -1;

            from = new int[k]; to = new int[k];
            for(int i = 0; i < k; i++){
                from[i] = in.nextInt(); to[i] = in.nextInt();
            }

            for(int i = 0; i < k + 10; i++){
                for(int j = 0; j < k; j++){
                    if(!can[to[j]])can[from[j]] = false;
                }
            }

            long rs = 0;
            for(int i = 1; i <= s; i++){
                if(!can[i])continue;
                rs += ans[i] - C[i];
            }

            out.println(rs);
          }
            int ja[][], from[],to[],c[];
            void make(int n,int m,InputReader in){
             ja=new int[n+1][];from=new int[m];to=new int[m];c=new int[n+1];
             for(int i=0;i<m;i++){
              int u=in.nextInt(),v=in.nextInt();
              c[u]++;c[v]++;from[i]=u;to[i]=v;
             }
             for(int i=1;i<=n;i++){
              ja[i]=new int[c[i]];c[i]=0;
             }
             for(int i=0;i<m;i++){
              ja[from[i]][c[from[i]]++]=to[i];
              ja[to[i]][c[to[i]]++]=from[i];
             }
            }
//        int[] radixSort(int[] f){ return radixSort(f, f.length); }
//    int[] radixSort(int[] f, int n)
//    {
//        int[] to = new int[n];
//        {
//            int[] b = new int[65537];
//            for(int i = 0;i < n;i++)b[1+(f[i]&0xffff)]++;
//            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
//            for(int i = 0;i < n;i++)to[b[f[i]&0xffff]++] = f[i];
//            int[] d = f; f = to;to = d;
//        }
//        {
//            int[] b = new int[65537];
//            for(int i = 0;i < n;i++)b[1+(f[i]>>>16)]++;
//            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
//            for(int i = 0;i < n;i++)to[b[f[i]>>>16]++] = f[i];
//            int[] d = f; f = to;to = d;
//        }
//        return f;
//    }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}