import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class peta {
    public static void main(String[] args) {
        reader = new BufferedReader(new InputStreamReader(System.in));
        int n = nextInt(), x = nextInt(), y = nextInt();
        int h = n / 2;
        for(int i = 0; i <= 1; ++i) {
            for(int j = 0; j <= 1; ++j) {
                if (x == h + i && y == h+ j) {
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }

    public static BufferedReader reader;

    public static StringTokenizer tokenizer = null;

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

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

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

    static public String next() {
        return nextToken();
    }

    static public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}


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

public class P2 {

	public void run() throws Exception {
		int n=getInt();
		int x=getInt();
		int y=getInt();
		if((x==n/2||x==n/2+1)&&(y==n/2||y==n/2+1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	public int getInt() throws Exception {
		return Integer.valueOf(getStringTokenizer().nextToken());
	}

	public long getLong() throws Exception {
		return Long.valueOf(getStringTokenizer().nextToken());
	}

	public double getDouble() throws Exception {
		return Double.valueOf(getStringTokenizer().nextToken());
	}

	public String getString() throws Exception {
		return reader.readLine();
	}

	private StringTokenizer token = null;
	private BufferedReader reader = new BufferedReader(new InputStreamReader(
			System.in));

	public StringTokenizer getStringTokenizer() throws Exception {
		if (token == null || !token.hasMoreTokens()) {
			String str = reader.readLine();
			token = new StringTokenizer(str);
		}
		return token;
	}

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

}


import java.math.BigInteger;
import java.util.*;

public class Main {
	static final int INF = 1000000007;
	static final Scanner sc = new Scanner(System.in);

	static int TC;
	static int N, M, K;
	static String S;
	static int[] freq = new int[256];
	static int[] tmp_freq = new int[256];
	static List<Character> vec_char = new ArrayList<>();
	static BigInteger result = BigInteger.ZERO;
	static BigInteger[] fact = new BigInteger[25];

	static BigInteger count_special(int len) {
		int N = len;
		BigInteger result = BigInteger.ZERO;
		for (char ch : vec_char) {
			if (ch == '0') continue;
			tmp_freq[ch] -= 1;
			BigInteger tmp_result = fact[N-1];
			for (char ch2 : vec_char) {
				if (tmp_freq[ch2] == 0) continue;
				tmp_result = tmp_result.divide(fact[tmp_freq[(int)ch2]]);
			}
			tmp_freq[ch] += 1;
			result = result.add(tmp_result);
		}
		return result;
	}

	static BigInteger count_possible() {
		int N = S.length();
		BigInteger result = fact[N];
		for (char ch : vec_char) {
			result = result.divide(fact[tmp_freq[ch]]);
		}
		return result;
	}

	static void recur(int pos, int len) {
		if (pos >= vec_char.size()) {
			if (tmp_freq['0'] == 0) result = result.add(count_possible());
			else result = result.add(count_special(len));
		} else {
			char cur_char = vec_char.get(pos);
			for (int i = 1; i <= freq[(int)cur_char]; i++) {
				tmp_freq[cur_char] = i;
				recur(pos+1, len+i);
			}
		}
	}

	public static void main(String[] args) {

		fact[1] = BigInteger.ONE;
		for (int i = 2; i <= 20; i++) {
			fact[i] = fact[i-1].multiply(BigInteger.valueOf(i));
		}

		S = sc.next();
		Set<Character> unik_char = new HashSet<>();

		for (char ch : S.toCharArray()) {
			freq[(int)ch] += 1;
			unik_char.add(ch);
		}
		vec_char = new ArrayList<>(unik_char);

		recur(0, 0);
		System.out.println(result);

		System.exit(0);
	}
}


import java.math.BigInteger;
import java.util.*;
public class Main {
	static long n;
	static int cnt[] = new int[10];
	static int num[] = new int[10];
	static long f[] = new long[20];
	static long ans = 0;
	public static void main(String arg[]) {

		f[0] = 1;
		for(int i = 1; i <= 18; i++) {
			f[i] = f[i - 1] * i;
		}

		Scanner in = new Scanner(System.in);
		n = in.nextLong();
		while(n > 0) {
			int ret = (int)(n % 10);
			cnt[ret]++;
			n /= 10;
		}

		for(int i = 0; i < 10; i++) {
			if(cnt[i] > 0) {
				num[i] = 1;
				cnt[i]--;
			}
		}

		dfs(0);
		System.out.println(ans);
		in.close();
	}

	public static void dfs(int p) {
		//System.out.println("#####");
		ans += cal();
		for(int i = p; i <= 9; i++) {
			if(cnt[i] == 0) continue;
			cnt[i]--;
			num[i]++;
			dfs(i);
			num[i]--;
			cnt[i]++;
		}
	}
	public static long cal() {
		int sum = 0;
		long ans = 0, ret = 0;
		for(int i = 0; i <= 9; i++) sum += num[i];
		ans = f[sum];

		for(int i = 0; i <= 9; i++) {
			if(num[i] > 0)ans /= f[num[i]];
		}

		if(num[0] > 0) {
			ret = f[sum - 1];
			ret /= f[num[0] - 1];
			for(int i = 1; i <= 9; i++) {
				if(num[i] > 0) {
					ret /= f[num[i]];
				}
			}
		}
		return ans - ret;

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EBusNumber solver = new EBusNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class EBusNumber {
        char[] arr;
        HashSet<Character> set;
        long memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            arr = sc.next().toCharArray();
            set = new HashSet<>();
            for (char c : arr)
                set.add(c);
            memo = new long[arr.length][1 << 18];
            for (long[] x : memo)
                Arrays.fill(x, -1);
            pw.println(dp(0, 0));
        }

        private long dp(int idx, int msk) {
            if (idx == arr.length) {
                return 1;
            }
            if (memo[idx][msk] != -1)
                return memo[idx][msk];
            boolean[] vis = new boolean[10];
            HashSet<Character> temp = new HashSet<>();
            for (int i = 0; i < arr.length; i++) {
                if ((msk & (1 << i)) != 0)
                    temp.add(arr[i]);
            }
            long sum = temp.size() == set.size() ? 1 : 0;
            for (int i = 0; i < arr.length; i++) {
                if (idx == 0 && arr[i] == '0' || (msk & (1 << i)) != 0 || vis[arr[i] - '0'])
                    continue;
                vis[arr[i] - '0'] = true;
                sum += dp(idx + 1, msk | 1 << i);
            }
            return memo[idx][msk] = sum;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

    }
}


import java.util.*;

public class Ideone {
	public static ArrayList<String> Data = new ArrayList<String>();

	public static long fact (int n) {
		if (n <= 1) return 1;
		else {
			long rez = 1;
			for (int i = 2; i <= n; i++) rez *= i;
			return rez;
		}
	}

	public static long P (int[] count) {
		int n = 0;
		for (int i = 0; i < 10; i++) n += count[i];
		long rez = fact(n);
		for (int i = 0; i < 10; i++) rez /= fact(count[i]);
		if (count[0] >= 1) {
			long dif = fact(n-1);
			dif /= fact(count[0]-1);
			for (int i = 1; i < 10; i++) dif /= fact(count[i]);
			rez -= dif;
		}
		return rez;
	}

	public static long Calc (int[] count) {
		long rez = P(count);
		int[][] counts  = new int[10][10];
		for (int i = 0; i < 10; i++) {
			if(count[i] != 0 && count[i] != 1) {
				for (int j = 0; j < 10; j++) counts[i][j] = count[j];
				counts[i][i]--;
				String str = "";
				for (int j = 0; j < 10; j++) str += counts[i][j] + '0';
				boolean contains = false;
				for (int j = 0; j < Data.size() && !contains; j++) if (Data.get(j) == str) contains = true;
				if (!contains) {
					Data.add(str);
					rez += Calc(counts[i]);
				}
			}
		}
		return rez;
	}

	public static void main (String[] args) {
		int count[] = {0,0,0,0,0,0,0,0,0,0};
		String str;
		Scanner imput = new Scanner(System.in);
		str = imput.nextLine();
		for (char a: str.toCharArray()) count[a-'0']++;
		System.out.print(Calc(count));
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(System.in);
        int n, t, sum;
        t = sc.nextInt();
        while(t-- > 0) {
            n = sc.nextInt();
            sum = 0;
            sum += n / 7;
            if(n % 7 == 1)
                sum += 2;
            else if(n % 7 > 1)
                sum++;
            System.out.println(sum);
        }
    }
}


import java.util.*;
public class CFS {
    public static void main (String [] args) {
        Scanner sc = new Scanner (System.in);
        int t = sc.nextInt();
        for(int i = 1; i <= t; i++)
          System.out.prinln((int)Math.ceil(sc.nextDouble()/2));
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication51;

//import java.util.Scanner;

/**
 *
 * @author Pascal-PC
 */
public class JavaApplication51 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int y=in.nextInt();
             System.out.println(y/7+1);
        }
    }

}


import java.util.Scanner;
public class Dice{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		int[] x = new int[t];
		int[] ans = new int[t];
		for(int i=0;i<t);i++){
			x[i]=s.nextInt();
			if((x[i]%7)!=1&&(x[i]%7)!=0)
			ans[i]=(x[i]/7)+1;
			if((x[i]%7)==0)
			ans[i]=(x[i]/7);
			if((x[i]%7)==1)
			ans[i]=(x[i]/7)+2;

		}
		for(int i=0;i<t);i++){
			System.out.println(x[i]);
		}
		s.close();
	}
}


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

public class test
{

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

	void run()
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int k = in.nextInt();
		boolean[] counts = new boolean[k];

		char[] arr = in.next().toCharArray();

		int i;

		int qcount = 0;
		int ccount = 0;

		for (i = 0; i < (arr.length % 2 == 0 ? arr.length / 2
				: (arr.length + 1) / 2); i++)
		{
			if (arr[i] == '?' || arr[arr.length - 1 - i] == '?')
			{
				if (arr[i] == '?' && arr[arr.length - 1 - i] == '?')
				{
					qcount++;
					continue;
				}
				else
				{
					char c = arr[i] == '?' ? arr[arr.length - 1 - i] : arr[i];
					arr[i] = c;
					arr[arr.length - 1 - i] = c;
				}
			}
			else if (arr[i] != arr[arr.length - 1 - i])
				break;

			if (!counts[arr[i] - 'a'])
			{
				counts[arr[i] - 'a'] = true;
				ccount++;
			}
		}

		for (i = 0; i < (arr.length % 2 == 0 ? arr.length / 2
				: (arr.length + 1) / 2); i++)
		{
			if (arr[i] == '?')
			{
				char c = 'a';

				if (qcount > 0 && qcount == (k - ccount))
				{
					int j = 0;
					for (; j < k; j++)
					{
						if (!counts[j])
							break;
					}

					c = (char) ('a' + j);

					ccount++;
				}

				arr[i] = c;
				arr[arr.length - 1 - i] = c;
				counts[c - 'a'] = true;
				qcount--;
			}
		}

		for (i = 0; i < k; i++)
			if (!counts[i])
				break;

		if (i < k)
			out.println("IMPOSSIBLE");
		else
			out.println(arr);
		out.close();
	}
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=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')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

    public static void sort(int arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(int arr[],int l1,int r1,int l2,int r2) {
        int tmp[]=new int[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void sort(long arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(long arr[],int l1,int r1,int l2,int r2) {
        long tmp[]=new long[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        int k=input.scanInt();
        StringBuilder str=new StringBuilder(input.scanString());
        boolean has[]=new boolean[26];
        for(int i=0;i<str.length();i++) {
            if(str.charAt(i)=='?') {
                continue;
            }
            has[str.charAt(i)-'a']=true;
        }
        for(int i=k;i<26;i++) {
            if(has[i]) {
                System.out.println("IMPOSSIBLE");
                return;
            }
        }
        ArrayList<Character> chr=new ArrayList<>();
        chr.add('a');
        for(int i=0;i<k;i++) {
            if(!has[i]) {
                chr.add((char)(i+'a'));
            }
        }
        int indx=chr.size();
        for(int i=str.length()/2+(str.length()%2)-1;i>=0;i--) {
            if(str.charAt(i)=='?' && str.charAt(str.length()-1-i)=='?') {
                str.setCharAt(i, chr.get(indx));
                str.setCharAt(str.length()-1-i, chr.get(indx));
                indx--;
            }
            if(str.charAt(i)=='?') {
                str.setCharAt(i, str.charAt(str.length()-1-i));
            }
            if(str.charAt(str.length()-1-i)=='?') {
                str.setCharAt(str.length()-1-i, str.charAt(i));
            }
            indx=Math.max(indx, 0);
            if(str.charAt(i)!=str.charAt(str.length()-1-i)) {
                System.out.println("IMPOSSIBLE");
                return;
            }
        }
        has=new boolean[k];
        for(int i=0;i<str.length();i++) {
            has[str.charAt(i)-'a']=true;
        }
        for(int i=0;i<k;i++) {
            if(!has[i]) {
                System.out.println("IMPOSSIBLE");
                return;
            }
        }
        System.out.println(str);
    }
}


//package Div2_55;

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

public class Title {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		String l = reader.readLine();
		char[] c = l.toCharArray();
		int[] a = new int[n];
		boolean can = true;
		for (int j = 0; j < c.length; j++) {
			if (c[j] != '?') {
				if ((c[j] - 'a') < a.length)
					a[c[j] - 'a']++;
			}
		}

		for (int i = 0; i < c.length / 2 && can; i++) {
			if (c[i] != '?' && c[c.length-1-i]!='?'&&c[i] != c[c.length - 1 - i])
				can = false;
			else if (c[i] == '?' && c[c.length - 1 - i] == '?') {
				char t = 'a';
				for (int j = 0; j < a.length; j++) {
					if (a[j] == 0)
					{
						t=(char)('a'+j);
						a[j] += 2;
						break;
					}
				}
				c[i] = t;
				c[c.length - 1 - i] = t;
			} else if (c[i] == '?')
				c[i] = c[c.length - 1 - i];
			else if (c[c.length - 1 - i] == '?')
				c[c.length - 1 - i] = c[i];
		}
		if (n % 2 == 1 && c[n / 2] == '?'){
			char t = 'a';
			for (int j = 0; j < a.length; j++) {
				if (a[j] == 0)
				{
					t=(char)('a'+j);
					a[j] += 2;
					break;
				}
			}
			c[n / 2] = t;
		}
		for (int i = 0; i < a.length; i++) {
			if (a[i] == 0){
				can = false;
				break;
			}
		}
		if (can){
			for (char m:c)
			System.out.print(m);

		}else
			System.out.println("IMPOSSIBLE");
		reader.close();
	}

}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		String s=r.readLine();
		int n=Integer.parseInt(s);
		s=r.readLine();
		char[] pal=new char[s.length()];
		boolean end=false;
		boolean[] used=new boolean[n];
		for(int i=0;i<s.length();i++){
			if(Character.isLetter(s.charAt(i))){
				used[s.charAt(i)-'a']=true;
			}
		}
		for(int i=0;i<s.length()/2;i++){
			char startC=s.charAt(i);
			char lastC=s.charAt(s.length()-1-i);
			if(Character.isLetter(startC)&&Character.isLetter(lastC)){
				if(startC==lastC){
					pal[i]=startC;
					pal[s.length()-1-i]=lastC;
				}
				else {
					System.out.println("IMPOSSIBLE");
					end=true;
					break;
				}
			}
			else if(startC=='?'&&lastC=='?'){
				int firstIndexUnUsed=unused(used);
				if(firstIndexUnUsed==-1){
					pal[i]='a';
					pal[s.length()-1-i]='a';
				}
				else{
				pal[i]=(char) ('a'+firstIndexUnUsed);
				pal[s.length()-1-i]=(char) ('a'+firstIndexUnUsed);
				used[firstIndexUnUsed]=true;
				}
			}
			else if(startC=='?'&&Character.isLetter(lastC)){
				pal[i]=lastC;
				pal[s.length()-1-i]=lastC;
			}
			else if(Character.isLetter(startC)&&lastC=='?'){
				pal[i]=startC;
				pal[s.length()-1-i]=startC;
			}
		}
		if(s.length()%2==1){
			int index=s.length()/2;
			if(Character.isLetter(s.charAt(index))){
				pal[index]=	s.charAt(index);
			}
			else {
				int firstIndexUnUsed=unused(used);
				if(firstIndexUnUsed==-1){
					pal[index]='a';
				}
				else{
				pal[index]=(char) ('a'+firstIndexUnUsed);
				used[firstIndexUnUsed]=true;
				}
			}
		}
		if(!end){
		boolean[] newU=new boolean[n];
		for(int i=0;i<pal.length;i++){
			newU[(int)pal[i]-'a']=true;
		}
		for(int i=0;i<newU.length;i++){
			if(newU[i]==false){
				System.out.println("IMPOSSIBLE");
				end=true;
				break;
			}
		}
		}
		if(!end){
				System.out.println(new String(pal));
		}
	}

	private static int unused(boolean[] used) {
		for(int i=0;i<used.length;i++){
			if(used[i]==false)
				return i;
		}
		return -1;
	}

}


import java.util.*;

public class CF672ASummerCamp {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());

		String line = "";

		for (int i = 1; i <= n; i++) s+=i;

		System.out.print(line.charAt(n-1));
    }
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main extends PrintWriter {
    final Random rand = new Random(31);
    final int inf = (int) 1e9;
    final long linf = (long) 1e18;

    final static String IO = "_std";

    void solve() throws IOException {
        int n = nextInt();
        List<Character> a = new ArrayList<>();
        for (int i = 1; a.size() < n; i++) {
            for (char c : Integer.toString(i).toCharArray()) {
                a.add(c);
            }
        }
        println(a.get(n - 1));
    }

    BufferedReader in;
    StringTokenizer stok;

    Main() {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    Main(String fileIn, String fileOut) throws IOException {
        super(fileOut);
        in = new BufferedReader(new FileReader(fileIn));
    }

    public static void main(String[] args) throws IOException {
        Main main;
        if ("_std".equals(IO)) {
            main = new Main();
        } else if ("_iotxt".equals(IO)) {
            main = new Main("input.txt", "output.txt");
        } else {
            main = new Main(IO + ".in", IO + ".out");
        }
        main.solve();
        main.close();
    }

    String next() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

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

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

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

    int[] nextIntArray(int len) throws IOException {
        int[] a = new int[len];
        for (int i = 0; i < len; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArraySorted(int len) throws IOException {
        int[] a = nextIntArray(len);
        shuffle(a);
        Arrays.sort(a);
        return a;
    }

    void shuffle(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int x = rand.nextInt(i + 1);
            int _ = a[i];
            a[i] = a[x];
            a[x] = _;
        }
    }

    void shuffleAndSort(int[] a) {
        shuffle(a);
        Arrays.sort(a);
    }

    boolean nextPermutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a) {
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        }
        return false;
    }

    <T> List<T>[] createAdjacencyList(int n) {
        List<T>[] res = new List[n];
        for (int i = 0; i < n; i++) {
            res[i] = new ArrayList<>();
        }
        return res;
    }

    void println(Object... a) {
        for (int i = 0; i < a.length; i++) {
            if (i != 0) {
                print(" ");
            }
            print(a[i]);
        }
        println();
    }
}

}


import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class main {
    public static void main(String args[])throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String g = new String();
        int i;
        for (i=0;i<1000;i++){
             g += i;
        }
        int n =in.nextInt();
        char t = g.charAt(n);
        out.print(t);
        out.close()
    }
}


public class Main {

	public static void main(String [] arg){
		StringBuilder sb=new StringBuilder();
		String number="";
		int N;
		for(int i=1;i<=370;i++){
			number=Integer.toString(i);
			sb.append(number);
			number="";
		}
		Scanner in = new Scanner(System.in);
		N=in.nextInt();
		System.out.println(sb.toString().charAt(N-1));
	}

}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.nextLine();
        int n = str.length();
        if(n <= 1) System.out.println("0");
        //else if (n <= 3) System.out.println("1");
        else {
            if(n % 2 != 0 && isZero(str.substring(1)) {
                System.out.println(n/2);
            } else if(n%2 == 0) System.out.println((n/2)+1);
            else System.out.println(n/2);
        }
    }

    private static boolean isZero(String s) {
        for(char c : s.toCharArray()) {
            if(c!='0') return fasle;
        }
        return true;
    }
}


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

public class BowWow {
 public static void main(String[] args) throws Exception {

       PrintWriter pw=new PrintWriter(System.out);

       BufferedReader br = new BufferedReader(
                              new InputStreamReader(System.in));

        InputReader in=new InputReader(System.in);

        char[] ch=in.nextLine().toCharArray();
        int n=ch.length;
        if(ch[0]=='0'){
            System.out.println("0");
            return;
        }
        for(int i=1;i<ch.length;i++){
            if(ch[i]=='1'){
                n++;
                break;
            }
        }
        pw.println(n/2);

        char[] n = in.nextLine().toCharArray();
         pw.flush(); //written for underlyind stream
         pw.close();

   }

   static class Pair implements Comparable<Pair>{
        int x;
        int y;
        Pair(int a,int b){ //creates a pair
            x=a;
            y=b;
        }
        public int compareTo(Pair t){
            if(x>t.x){
                       return 1;
            }
            else if(x==t.x){
                if(y>=t.y){
                 return 1;
                }
                else {
                    return -1;
                }
            }
            else {
                    return -1;
            }
        }
        public boolean equals(Object obj){
            if(this==obj)return true;
            Pair that=(Pair)obj;
            if(this.x==that.x && this.y==that.y)return true;
            return false;
        }
         public boolean equals(Object obj){
            if(this==obj)return true;
            Pair that=(Pair)obj;
            if(this.x==that.x && this.y==that.y)return true;
            return false;
        }

        public String toString(){
            return this.x+" "+this.y;
        }
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        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 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;
        }

        public String nextString() {
            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 String next() {
            return nextString();
        }

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

        }

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class a_bowwow {

		public static void main(String args[]) throws Exception{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String s = br.readLine();
			char[] a = new char[s.length()];
			a = s.toCharArray();
			double[] n = new double[s.length()];
			double t, sol = 0;
			int count = 0;

			for(int i=0; i<s.length(); i++) {
				n[s.length()-i]=(double)a[i];
			}

			for(int j = 0; j<s.length(); j--) {
				t = 2^j;
				sol = n[j]*t;
			}

			while(sol>1){
				sol /= 4;
				count ++;
			}

			System.out.println(count);

		}
	}

}


import java.util.Scanner;

public class Sol
{
    public static void main(String srgs[])
    {
        Scanner sc = new Scanner(System.in);
        BigInteger b = new BigInteger(sc.next(),2);
        System.out.print(Math.log(b)/Math.log(4));
    }
}


import java.util.Scanner;

public class Maximum {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int[] arr = new int[a];

		for(int i=0; i<a; i++) {
			arr[i] = b;
		}

		for(int i=0; i<c; i++) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            int r = sc.nextInt();

            for(int j=p-1; j<=q-1; j++) {
            	if(i != 1) {
            		arr[j] > r;
            		continue;
            	}
            	else {
            		arr[j] = r;

            	}

            }
		}

        int sum = 0;

		for(int i=0; i<a; i++) {
			sum += arr[i]*arr[i];
		}

		System.out.println(sum);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.BufferedInputStream;
import java.io.IOException;
public final class codeforces {
    public static void main(String[]args)
    {
        Scanner scan = new Scanner(System.in);
       int n  = scan.nextInt();
        int h  = scan.nextInt();
        int m  = scan.nextInt();
        int i = 0;
        int[] houses = new int[n];
        boolean[] flag = new boolean[n];
        int[] heights = new int[n];
        int[] restrictions = new int[n];
        Map<Integer,Integer> hm = new HashMap<>();
        i = 0;
        while(i<n)
        {
            hm.put(i+1,h);
            i++;
        }
        i = 0;
        while(i < m)
        {
            int house1 = scan.nextInt();
            int house2 = scan.nextInt();
            int maxheight = scan.nextInt();
            int height2 = maxheight;
            int height3 = maxheight;
            int z = house1;
            while(z <= house2)
            {
                int maxheight1 = Math.min(hm.get(z), maxheight);
                hm.put(z,maxheight2);
                z++;
            }
            i++;

        }
        long profit = 0;
        for(Map.Entry<Integer,Integer> entry: hm.entrySet())
                profit += Math.pow(entry.getValue(),2);
        i = 0;
        System.out.println(profit);

    }
}


import java.util.*;

public class Zone {
	static int[][] min(int arrold[][],int mo) {
		int arr[][] = new int[mo][3];
		for(int j=0;j<mo;j++)
			for(int k=0;k<3;k++)
				arr[j][k] = arrold[j][k];
		for(int i=0;i<mo-1;i++) {
			if(arr[i][1]==arr[i+1][0]) {
				if(arr[i][2]<arr[i+1][2]) {
					if(arr[i+1][0] != arr[i+1][1]) {
						arr[i+1][0]++;
					}
					else if(arr[i+1][0]==arr[i+1][1]) {
						arr[i+1][2] = 0;
					}
				}
				if(arr[i][2]>arr[i+1][2]) {
					if(arr[i][0] != arr[i][1]) {
						arr[i][1]--;
					}
					else if(arr[i][0]==arr[i][1]) {
						arr[i][2] = 0;
					}
				}
			}
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		int r[][]= new int[m][3];
		int a[] = new int[n];
		Arrays.fill(a,h);
		for(int i=0;i<m;i++) {
			r[i][0] = sc.nextInt();
			r[i][1] = sc.nextInt();
			r[i][2] = sc.nextInt();
		}
		r = min(r,n,m);
		for(int i=0;i<m;i++) {
			if(r[i][1]-r[i][0]==0)
				a[(r[i][0])-1]=r[i][2];
			else if(r[i][1]-r[i][0]>0) {
				for(int j=r[i][0];j<=r[i][1];j++)
					a[j-1] = r[i][2];
			}
		}
		int sum = 0;
		for(int q=0;q<n;q++) {
			sum = sum + (a[q]*a[q]);
		}
		System.out.println(sum);
	}

}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int h=s.nextInt();
		int m=s.nextInt();
		int a[]=new int [n];
		int ans=0;
		for(int i=0;i<m;i++)
		{
		    int l=s.nextInt();
		    int r=s.nextInt();
		    int x=s.nextInt();
		    for(int j=l-1;j<r;j++)
		    {
		        if(a[j]>x&&a[j]>0)
		        a[j]=x;
		        else if(a[j]==0)
		        a[j]=x;
		        else if(x==0)
		        {
		            a[j]=1;
		            ans=ans-(r-l+1);
		        }
		    }
		}
		for(inyt i=0;i<n;i++)
		{
		    if(a[i]==0)
		    a[i]=h;
		}
		for(int i=0;i<n;i++)
		{
		    ans=ans+a[i]*a[i];
		}
		System.out.println(ans);
	}
}


import java.util.*;
public class ctask{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int[] px = new int[4];
		int[] py = new int[4];

		int[] ix = new int[4];
		int[] iy = new int[4];

		for(int i = 0;i < 4;i++){
			px[i] = s.nextInt();
			py[i] = s.nextInt();
		}

		for(int i = 0;i < 4;i++){
			ix[i] = s.nextInt();
			iy[i] = s.nextInt();
		}

		Arrays.sort(px);
		Arrays.sort(py);
		int minx = px[0] , maxx = px[3];
		int miny = py[0] , maxy = py[3];

		Arrays.sort(ix);
		Arrays.sort(iy);

		int inxmin = ix[0] , inxmax = ix[3];
		int inymin = iy[0] , inymax = iy[3];

		int flag = 0;
		if(inxmin >= minx && inxmin <= maxx){
			if(inymin >= miny && inymin <= maxy){
				flag = 1;
			}
		}
		else if(inxmax >= minx && inxmax <= maxx){
			if(inymax >= miny && inymax <= maxy){
				flag = 1;
			}
		}

		if(flag == 1)
			System.out.println("YES");
		else
			System.out.println("NO");

	}
}


import sun.rmi.transport.DGCImpl_Stub;

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

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));

//        String fileName = "C-large";
//        ConsoleIO io = new ConsoleIO(new FileReader("D:\\Dropbox\\code\\practice\\jb\\src\\" + fileName + ".in"), new PrintWriter(new File("D:\\Dropbox\\code\\practice\\jb\\src\\" + fileName + ".out")));

        new Main(io).solve();
//        new Main(io).solveLocal();

        io.close();
    }

    ConsoleIO io;
    Main(ConsoleIO io) {
        this.io = io;
    }
    ConsoleIO opt;
    Main(ConsoleIO io, ConsoleIO opt) {
        this.io = io; this.opt = opt;
    }

    List<List<Integer>> gr = new ArrayList<>();
    long MOD = 1_000_000_007;

    public void solve() {
        int[] par = io.readIntArray();
        int[] ang = io.readIntArray();
        for(int i = 0;i<par.length;i++){
            par[i]+=100;
            ang[i]+=100;
        }
        int[][] map = new int[201][201];

        int cax = (ang[0]+ang[2]+ang[4]+ang[6])/4;
        int cay = (ang[1]+ang[3]+ang[5]+ang[7])/4;

        int lx = Math.min(Math.min(ang[0],ang[2]), Math.min(ang[4], ang[6]));
        int rx = Math.max(Math.max(ang[0],ang[2]), Math.max(ang[4], ang[6]));
        int ly = Math.min(Math.min(ang[1],ang[3]), Math.min(ang[5], ang[7]));
        int ry = Math.max(Math.max(ang[1],ang[3]), Math.max(ang[5], ang[7]));
        for(int i = lx; i<=rx;i++){
            for(int j = cay-(i-lx); j<= cay+(i-lx); j++){
                map[i][j] |= 1;
            }
        }

        lx = Math.min(Math.min(par[0],par[2]), Math.min(par[4], par[6]));
        rx = Math.max(Math.max(par[0],par[2]), Math.max(par[4], par[6]));
        ly = Math.min(Math.min(par[1],par[3]), Math.min(par[5], par[7]));
        ry = Math.max(Math.max(par[1],par[3]), Math.max(par[5], par[7]));
        for(int i = lx;i<=rx;i++)
            for(int j = ly;j<=ry;j++)
                if(map[i][j] != 0){
                    io.writeLine("YES");
                    return;
                }
        io.writeLine("NO");
    }
}

class ConsoleIO {

    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(Reader reader, PrintWriter writer){br = new BufferedReader(reader);out = writer;}
    public void flush(){this.out.flush();}
    public void close(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public void writeIntArray(int[] a, int k, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < k; i++) {
            if (i > 0) sb.append(separator);
            sb.append(a[i]);
        }
        this.writeLine(sb.toString());
    }
    public int read(char[] buf, int len){try {return br.read(buf,0,len);}catch (Exception ex){ return -1; }}
    public String readLine() {try {return br.readLine();}catch (Exception ex){ return "";}}
    public long[] readLongArray() {
        String[]n=this.readLine().trim().split("\\s+");long[]r=new long[n.length];
        for(int i=0;i<n.length;i++)r[i]=Long.parseLong(n[i]);
        return r;
    }
    public int[] readIntArray() {
        String[]n=this.readLine().trim().split("\\s+");int[]r=new int[n.length];
        for(int i=0;i<n.length;i++)r[i]=Integer.parseInt(n[i]);
        return r;
    }
    public int[] readIntArray(int n) {
        int[] res = new int[n];
        char[] all = this.readLine().toCharArray();
        int cur = 0;boolean have = false;
        int k = 0;
        boolean neg = false;
        for(int i = 0;i<all.length;i++){
            if(all[i]>='0' && all[i]<='9'){
                cur = cur*10+all[i]-'0';
                have = true;
            }else if(all[i]=='-') {
                neg = true;
            }
            else if(have){
                res[k++] = neg?-cur:cur;
                cur = 0;
                have = false;
                neg = false;
            }
        }
        if(have)res[k++] = neg?-cur:cur;
        return res;
    }
    public int ri() {
        try {
            int r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public long readLong() {
        try {
            long r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public String readWord() {
        try {
            boolean start = false;
            StringBuilder sb = new StringBuilder();
            while (true) {
                int c = br.read();
                if (c!= ' ' && c!= '\r' && c!='\n' && c!='\t') {
                    sb.append((char)c);
                    start = true;
                } else if (start || c == -1) return sb.toString();
            }
        } catch (Exception ex) {
            return "";
        }
    }
    public char readSymbol() {
        try {
            while (true) {
                int c = br.read();
                if (c != ' ' && c != '\r' && c != '\n' && c != '\t') {
                    return (char) c;
                }
            }
        } catch (Exception ex) {
            return 0;
        }
    }
//public char readChar(){try {return (char)br.read();}catch (Exception ex){ return 0; }}
}
class Pair {
    public Pair(int a, int b) {this.a = a;this.b = b;}
    public int a;
    public int b;
}
class PairLL {
    public PairLL(long a, long b) {this.a = a;this.b = b;}
    public long a;
    public long b;
}
class Triple {
    public Triple(int a, int b, int c) {this.a = a;this.b = b;this.c = c;}
    public int a;
    public int b;
    public int c;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	static boolean visited[] ;
	static boolean ends[] ;
	static long mod = 1000000007 ;
	static int lens[] ;
	static int seeds[] ;
	static int a[] ;
	static double total ;
	public static ArrayList adj[] ;
	public static long x,y ;
	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc =  new Scanner(System.in) ;

		int x1[]= new int[4] ;
		int y1[]= new int[4] ;
		int x2[] = new int[4] ;
		int y2[] = new int[4] ;

		//sss

		for (int i = 0; i < 4; i++)
		{
			x1[i]=sc.nextInt() ;
			y1[i]=sc.nextInt() ;

		}
		for (int i = 0; i < 4 ;i++)
		{
			x2[i]=sc.nextInt() ;
			y2[i]=sc.nextInt() ;
		}

		Arrays.sort(x1);
		Arrays.sort(x2);
		Arrays.sort(y1);
		Arrays.sort(y2);

		int h=y2[3]-y2[0] ;
		h=h/2 ;
		int begin=y2[0]+h ;
		HashMap<point, Integer> map =  new HashMap<point,Integer>() ;

		for (int i = 0; i <=h; i++)
			for (int j = x2[0]+i; j <=x2[3]-i; j++)
			{
				map.put(new point(j,begin+i),0) ;
				map.put(new point(j,begin-i),0) ;
			}

		for (int i = x1[0]; i <= x1[3]; i++)
			for (int j =y1[0]; j <= y1[3]; j++)
			{
				point p = new point(i , j);
				if(map.containsKey(p))
				{System.out.println("YES"); return ;}
			}

		System.out.println("NO");

	}

	public static int neededFromLeft(String x)
	{
		Stack<Character> st = new Stack<Character>() ;
		int c=0;

		for (int i = 0; i < x.length(); i++)
		{
			char cur = x.charAt(i);
			if(cur==')' && st.isEmpty())
				c ++;
			else if(cur==')' && !st.isEmpty())
				st.pop();
			else if(cur=='(')
				st.push(cur);
		}
		return c;
	}

	public static int neededFromRight(String x)
	{
		Stack<Character> st = new Stack<Character>() ;
		int c=0;
		boolean f=true;
		for (int i = 0; i < x.length(); i++)
		{
			char cur = x.charAt(i);
			if(cur==')' && st.isEmpty())
				f=false;
			else if(cur==')' && !st.isEmpty())
				st.pop();
			else if(cur=='(')
				st.push(cur);
		}
		return st.size();
	}

	public static boolean fromBoth(String x)
	{
		Stack<Character> st = new Stack<Character>() ;
		boolean f1=true ,f2=true ;

		for (int i = 0; i < x.length(); i++)
		{
			char cur = x.charAt(i);
			if(cur==')' && st.isEmpty())
				f1 =false ;
			else if(cur==')' && !st.isEmpty())
				st.pop();
			else if(cur=='(')
				st.push(cur);
		}
		if(st.size()>0)f2 = false ;

		if(f1==false && f2==false)
			return true ;
		else
			return false;
	}

	public static boolean isRegular(String x)
	{
		Stack<Character> st = new Stack<Character>() ;
		for (int i = 0; i < x.length(); i++)
		{
			char cur = x.charAt(i);
			if(cur==')' && st.isEmpty())
				return false ;
			else if(cur==')' && !st.isEmpty())
				st.pop();
			else if(cur=='(')
				st.push(cur);
		}
		if(st.size()>0)return false ; else return true ;
	}

	public static int gcdExtended(int a, int b)
	{
		// Base Case
		if (a == 0)
		{
			x = 0;
			y = 1;
			return b;
		}

		//int x1=1, y1=1; // To store results of recursive call
		int gcd = gcdExtended(b%a, a);

		// Update x and y using results of recursive
		// call
		long x1 = y - (b/a) * x;
		long y1 = x;
		x = x1 ;
		y = y1 ;

		return gcd;
	}

	static int even(String x , int b )
	{
		for (int j = b; j>=0; j--)
		{
			int current = x.charAt(j)-48 ;
			if(current%2==0)
				return current ;
		}
		return -1;
	}
	static int odd(String x , int b )
	{
		for (int j = b; j>=0; j--)
		{
			int current = x.charAt(j)-48 ;
			if(current%2!=0)
				return current ;
		}
		return -1;
	}
	static long pow(long base, int exp) {
		long res = 1;
		while(exp > 0) {
			if(exp % 2 == 1) {
				res = (res * base) % mod;
			}

			base = (base * base) % mod;
			exp /= 2;
		}

		return res;
	}
	public static long solve(int k1, long k2)
	{
		long x   = 1l*k2*(pow(2, k1)-1) ;
		return x%(1000000007) ;
	}

	public static long getN(long x)
	{
		long n = (long) Math.sqrt(x*2) ;
		long y = n*(n+1)/2;
		if(y==x)
			return n ;
		else if(y>x)
			return n ;
		else
			for (long i = n; ; i++)
			{
				y = i*(i+1)/2 ;
				if(y>=x)
					return i ;

			}	}

	public static void dfss(int root , int len)
	{
		visited[root]=true ;
		if(ends[root] && root!=0) lens[root] = len ;

		for (int i = 0; i < adj[root].size(); i++)
		{
			int c= (int) adj[root].get(i) ;
			if(visited[c]==false)
				dfss(c, len+1);
		}
	}

	public static void pr(int root ,  int seed){
		visited[root] = true ;
		int dv = adj[root].size()-1 ;
		if(root==0) dv++ ;

		for (int i = 0; i < adj[root].size(); i++)
		{
			int c = (int)adj[root].get(i) ;
			seeds[c]=dv*seed ;
		}

		for (int i = 0; i < adj[root].size() ; i++)
		{
			int c = (int)adj[root].get(i) ;
			if(visited[c]==false)
				pr(c , seeds[c]);

		}

	}

	public static String concatinate(String s ,int n)
	{
		if(s.length()==n)
			return s ;
		else return concatinate("0"+s, n) ;
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		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();
		}
	}

	public static long getGCD(long n1, long n2) {
		if (n2 == 0) {
			return n1;
		}
		return getGCD(n2, n1 % n2);
	}

	public static int cnt1(int mat[][])  //how many swaps to be a 1 matrix
	{
		int m = mat.length ;
		int c=0 ;
		for (int i = 0; i < mat.length; i++)
		{
			for (int j = 0; j < mat.length; j++)
			{
				int x =  (i*m) +j ;
				if(x%2==0 && mat[i][j]==0)
					c++;
				if(x%2!=0 && mat[i][j]==1)
					c++;

			}
		}
		return c;
	}
	public static int cnt0(int mat[][])
	{
		int m = mat.length ;
		int c=0 ;
		for (int i = 0; i < mat.length; i++)
		{
			for (int j = 0; j < mat.length; j++)
			{
				int x =  (i*m) +j ;
				if(x%2!=0 && mat[i][j]==0)
					c++;
				if(x%2==0 && mat[i][j]==1)
					c++;

			}
		}
		return c;
	}

	public static boolean canFit2(int x1, int y1 , int x2 , int y2 , int x3 , int y3){
		if(x1==x2)
			if(x1==x3)
				return true ;
			else
				return false ;
		else
			if(x1==x3)
				return false ;
			else
			{
				long a = 1l*(y2-y1)*(x3-x2) ;
				long b = 1l*(y3-y2)*(x2-x1) ;

				if(a==b)
					return true;
				else
					return false ;

			}

	}
	public static void shuffle(pair[] ss){
		if(ss.length==1)
			return ;
		for (int i = 0; i < ss.length; i++)
		{
			Random rand = new Random();

			int  n = rand.nextInt(ss.length-1) + 0;

			pair temp = ss[i] ;
			ss[i] = ss[n] ;
			ss[n] = temp ;
		}
	}
	public static int binary(ArrayList<pair> arr, int l, int r, long x)   /// begin by 0 and n-1
	{
		if (r>=l)
		{
			int mid = l + (r - l)/2;
			if (arr.get(mid).x== x)
				return mid;
			if (arr.get(mid).x> x)
				return binary(arr, l, mid-1, x);
			return binary(arr, mid+1, r, x);
		}
		return -1;
	}

	/// searching for the index of first elment greater than x
	public static int binary1(int[]arr , int x) {
		int low = 0, high = arr.length; // numElems is the size of the array i.e arr.size()
		while (low != high) {
			int mid = (low + high) / 2; // Or a fancy way to avoid int overflow
			if (arr[mid] <= x) {
				/* This index, and everything below it, must not be the first element
				 * greater than what we're looking for because this element is no greater
				 * than the element.
				 */
				low = mid + 1;
			}
			else {
				/* This element is at least as large as the element, so anything after it can't
				 * be the first element that's at least as large.
				 */
				high = mid;
			}
		}
		return low ; // return high ;
	}

	////// searching for last element less than X
	public static int binary2(pair[]arr , int x) {
		int low = 0, high = arr.length; // numElems is the size of the array i.e arr.size()
		while (low != high) {
			int mid = (low + high) / 2; // Or a fancy way to avoid int overflow
			if (arr[mid].x >= x) {
				/* This index, and everything below it, must not be the first element
				 * greater than what we're looking for because this element is no greater
				 * than the element.
				 */
				high=mid;
			}
			else {
				/* This element is at least as large as the element, so anything after it can't
				 * be the first element that's at least as large.
				 */
				low = mid+1 ;
			}
		}
		return low ; // return high ;
	}

	private static boolean triangle(int a, int b , int c){
		if(a+b>c && a+c>b && b+c>a)
			return true ;
		else
			return false ;
	}
	private static boolean segment(int a, int b , int c){
		if(a+b==c || a+c==b && b+c==a)
			return true ;
		else
			return false ;
	}
	private static int gcdThing(long a, long b) {
		BigInteger b1 = BigInteger.valueOf(a);
		BigInteger b2 = BigInteger.valueOf(b);
		BigInteger gcd = b1.gcd(b2);
		return gcd.intValue();
	}

	public static boolean is(int i){
		if(Math.log(i)/ Math.log(2) ==(int) (Math.log(i)/ Math.log(2)))
			return true ;
		if(Math.log(i)/ Math.log(3) ==(int) (Math.log(i)/ Math.log(3)) )
			return true ;
		if(Math.log(i)/ Math.log(6) ==(int) (Math.log(i)/ Math.log(6)) )
			return true ;

		return false;

	}
	public static boolean contains(int b[] , int x)
	{
		for (int i = 0; i < b.length; i++)
		{
			if(b[i]==x)
				return true ;
		}
		return false ;
	}
	public static int binary(long []arr , long target , int low , long shift) {
		int high = arr.length;
		while (low != high) {
			int mid = (low + high) / 2;
			if (arr[mid]-shift <= target) {
				low = mid + 1;
			}
			else {
				high = mid;
			}
		}
		return low ; // return high ;
	}
	public static boolean isLetter(char x){
		if(x+0 <=122 && x+0 >=97 )
			return true ;
		else if (x+0 <=90 && x+0 >=65 )
			return true ;
		else return false;
	}
	public static long getPrimes(long x ){
		if(x==2 || x==3 || x==1)
			return 2 ;
		if(isPrime(x))
			return 5 ;
		for (int i = 2; i*i<=x; i++)
		{
			if(x%i==0 && isPrime(i))
				return getPrimes(x/i) ;
		}
		return -1;
	}
	public static String solve11(String x){

		int n = x.length() ;
		String y = "" ;
		for (int i = 0; i < n-2; i+=2)
		{
			if(ifPalindrome(x.substring(i, i+2)))
				y+= x.substring(i, i+2) ;
			else
				break ;
		}
		return y+ solve11(x.substring(y.length(),x.length())) ;

	}
	public static String solve1(String x){
		String y = x.substring(0 , x.length()/2) ;
		return "" ;

	}
	public static String reverse(String x){
		String y ="" ;
		for (int i = 0; i < x.length(); i++)
		{
			y  = x.charAt(i) + y ;
		}
		return y ;
	}

	public static boolean ifPalindrome(String x){
		int numbers[] = new int[10] ;
		for (int i = 0; i < x.length(); i++)
		{
			int z = Integer.parseInt(x.charAt(i)+"") ;
			numbers[z] ++ ;
		}
		for (int i = 0; i < numbers.length; i++)
		{
			if(numbers[i]%2!=0)
				return false;
		}
		return true ;
	}

	public static int get(int n){
		return n*(n+1)/2 ;
	}
	//		public static long getSmallestDivisor( long y){
	//			if(isPrime(y))
	//				return -1;
	//
	//			for (long i = 2; i*i <= y; i++)
	//			{
	//				if(y%i ==0)
	//				{
	//					return i;
	//				}
	//			}
	//			return -1;
	//		}
	public static int lis( int[]a , int n){
		int lis[] = new int[n] ;
		Arrays.fill(lis,1) ;

		for(int i=1;i<n;i++)
			for(int j=0 ; j<i; j++)
				if (a[i]>a[j] &&  lis[i] < lis[j]+1)
					lis[i] = lis[j] + 1;

		int max = lis[0];

		for(int i=1; i<n ; i++)
			if (max < lis[i])
				max = lis[i] ;
		return (max);

		//			ArrayList<Integer> s = new ArrayList<Integer>() ;
		//			for (int i = n-1; i >=0; i--)
		//			{
		//				if(lis[i]==max)
		//				{
		//					s.add(a[i].z);
		//					max --;
		//				}
		//			}
		//
		//			for (int i = s.size()-1 ; i>=0 ;  i--)
		//			{
		//				System.out.print(s.get(i)+" ");
		//			}
		//
	}
	public static int calcDepth(Vertix node){
		if(node.depth>0) return node.depth;
		// meaning it has been updated before;
		if(node.parent != null)
			return 1+ calcDepth(node.parent);
		else
			return -1;
	}

	public static boolean isPrime (long num){
		if (num < 2) return false;
		if (num == 2) return true;
		if (num % 2 == 0) return false;
		for (int i = 3; i * i <= num; i += 2)
			if (num % i == 0) return false;
		return true;
	}

	public static ArrayList<Long> getDiv(Long n)
	{
		ArrayList<Long>  f = new ArrayList<Long>() ;

		while (n%2==0)
		{
			if(!f.contains(2))f.add((long) 2) ;
			n /= 2;
		}

		// n must be odd at this point.  So we can
		// skip one element (Note i = i +2)
		for (long i = 3; i <= Math.sqrt(n); i+= 2)
		{
			// While i divides n, print i and divide n
			while (n%i == 0)
			{
				if(!f.contains(i))f.add(i);
				n /= i;
			}
		}

		// This condition is to handle the case whien
		// n is a prime number greater than 2
		if (n > 2)
			if(!f.contains(n))f.add(n);

		return f ;

	}

	//		public static boolean dfs(Vertix v , int target){
	//			try{
	//				visited[v.i]= true ;
	//			} catch (NullPointerException e)
	//			{
	//				System.out.println(v.i);
	//			}
	//			if(v.i == target)
	//
	//				return true ;
	//			for (int i =0 ; i< v.neighbours.size() ; i++)
	//			{
	//
	//				Vertix child = v.neighbours.get(i) ;
	//				if(child.i == target){
	//					found = true  ;
	//				}
	//				if(visited[child.i]==false){
	//					found |= dfs(child, target) ;
	//				}
	//			}
	//			return found;
	//		}

	public static class Vertix{
		long i ;
		int depth ;
		ArrayList<Vertix> neighbours ;
		Vertix parent ;
		Vertix child ;

		public Vertix(long i){
			this.i = i ;
			this.neighbours = new ArrayList<Vertix> () ;
			this.parent = null ;
			depth =-1;
			this.child = null ;
		}
	}

	public static class pair implements Comparable<pair> {
		int x ;
		int y ;
		int i;

		public pair(int x, int y, int i ){

			this.x=x ;
			this.y =y ;
			this.i =i ;

		}

		@Override
		public int compareTo(pair p) {
			if(this.x > p.x)
				return 1 ;
			else if (this.x == p.x)
				return 0 ;
			else
				return -1 ;
		}

	}

	public static class pair2 implements Comparable<pair2>{
		int i ;
		int j ;
		int plus ;

		public pair2(int i , int j , int plus){
			this.i =i ;
			this.j = j ;
			this.plus = plus ;
		}

		@Override
		public int compareTo(pair2 p) {
			if(this.j > p.j)
				return 1 ;
			else if (this.j == p.j) return 0 ;
			else
				return -1 ;
		}

	}
	public static class point implements  Comparable<point>
	{
		int x, y ;
		public point(int x,int y){
			this.x=x ; this.y=y;
		}
		@Override
		public boolean equals(Object o) {

			// If the object is compared with itself then return true
			if (o == this) {
				return true;
			}

			/* Check if o is an instance of Complex or not
	          "null instanceof [type]" also returns false */
			if (!(o instanceof point)) {
				return false;
			}

			// typecast o to Complex so that we can compare data members
			point c = (point) o;

			// Compare the data members and return accordingly
			return Integer.compare(x, c.x) == 0
					&& Integer.compare(y, c.y) == 0;
		}
		@Override
		public int compareTo(point p) {
			if(this.x == p.x && this.y ==p.y)
				return 0 ;
			else
				return -1 ;
		}

		@Override
		public int hashCode()
		{
			return 15+x+(2%y) ;
		}

	}

}


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

public class Main {

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

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            //in = new Reader("input.txt");
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws Exception {

        long time = System.currentTimeMillis();

        //int t = in.nextInt();
        int t = 1;
        while (t > 0) {
            solve();
            t--;
        }

        //System.err.println(System.currentTimeMillis() - time);

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200000];

    void solve() throws IOException {

        Pair[] s1 = new Pair[4];
        Pair[] s2 = new Pair[4];

        int lx = 100;
        int rx = -100;
        int ty = -100;
        int by = 100;

        for (int i = 0; i < 4; i++) {
            s1[i] = new Pair(in.nextInt(), in.nextInt());
            lx = Math.min(lx, s1[i].a);
            rx = Math.max(rx, s1[i].a);
            ty = Math.max(ty, s1[i].b);
            by = Math.min(by, s1[i].b);
        }

        int lx2 = 100;
        int rx2 = -100;
        int ty2 = -100;
        int by2 = 100;

        for (int i = 0; i < 4; i++) {
            s2[i] = new Pair(in.nextInt(), in.nextInt());
            lx2 = Math.min(lx2, s2[i].a);
            rx2 = Math.max(rx2, s2[i].a);
            ty2 = Math.max(ty2, s2[i].b);
            by2 = Math.min(by2, s2[i].b);
        }

        boolean cw = area(s2[0].a, s2[0].b, s2[1].a, s2[1].b, s2[2].a, s2[2].b) < 0;

        boolean inq = false;
        inq = lx2 <= lx && rx2 >= rx && ty2 >= ty(ty2+by2)/2 >= by && (ty2+by2)/2 <= ty && (lx2+rx2)/2 >= lx && (lx2+rx2)/2 <= rx;
        for (int i = 0; i < 4; i++) {

            int x = s2[i].a;
            int y = s2[i].b;
            inq |= x >= lx && x <= rx && y >= by && y <= ty;

            boolean all = true;
            for (int j = 0; j < 4; j++) {
                int area = area(s2[j].a, s2[j].b, s1[i].a, s1[i].b, s2[(j+1)%4].a, s2[(j+1)%4].b);
                if (cw) all &= area >= 0;
                else all &= area <= 0;
            }

            inq |= all;
        }

        if (inq)
            out.println("YES");
        else
            out.println("NO");

    }

    int area (int x1, int y1, int x2, int y2, int x3, int y3) {
        return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

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

    }

    static class InputReader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public InputReader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public InputReader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

}


import java.util.*;
 public class solution{
     public void minval(int n)
     {
         ArrayList<Integer> aa=new ArrayList<>();
         int max=9;
         int res=0;
         while(n!=0){
             if(n>max){
                 al.add(max);
                 n-max=max;
                 max--;
             }
            else{
                al.add(n);
                n=0;
            }

         }
         for(int i=al.size()-1;i>=0;i--){
             res=res*10+al.get(i);
         }
         System.out.println(res);
     }
 }
 public class mm{
     public static void main(String[] arg){
         Scanner sc=new Scanner(System.in);
         solution s=new solution();
         int t=sc.nextInt();
         while(j>0){
             int j=sc.nextInt();
             s.minval(j);
             j--;
         }
     }
 }


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

public class Main {

    public static void main(String[] args) {
        new Thread(null, () -> new Main().run(), "1", 1 << 23).start();
    }

    private void run() {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Solution solve = new Solution();
        int t = scan.nextInt();
        //int t = 1;
        for (int qq = 0; qq < t; qq++) {
            solve.solve(scan, out);
            //out.println();
        }
        out.close();
    }
}

class Solution {
    /*
     * think and coding
     */
    double EPS = 0.000_0001;

    public void solve(FastReader scan, PrintWriter out) {
//        int n = scan.nextInt(), H = scan.nextInt(), M = scan.nextInt();
//        int[][] arr = new int[n][2];
//        int min = 23456756, index = 0;
//        for (int i = 0; i < n; i++) {
//            arr[i][0] = scan.nextInt();
//            arr[i][1] = scan.nextInt();
//            if (min < minut(H, M, arr[i][0], arr[i][1])) {
//                min = minut(H, M, arr[i][0], arr[i][1]);
//                index = i;
//            }
//        }
//        out.println();
        int n = scan.nextInt();
        if (n < 10) {
            out.println(n);
            return;
        }
        int sum = 0;
        String s = ""
        for (int i = 9; i > 0 && sum < n; i--) {
            if (sum + i >= n) {
                i = n - sum;
                sum = n;
            } else {
                sum += i;
            }
            s += i + "";
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            out.print(s.charAt(i));
        }
        out.println();
    }

    int minut(int h, int m, int h1, int m2) {
        if (m > m2) {
            m2 += 60;
            h1--;
        }
        return (h1 - h * 60) + m2 - m;
    }

    static class Pair implements Comparable<Pair> {
        int a, b;

        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Pair p) {
            return Integer.compare(a, p.a);
        }
    }
}

class FastReader {
    private final BufferedReader br;
    private StringTokenizer st;

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

    public FastReader(String s) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(new File(s)));
    }

    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.*;
 public class solution{
    public void minval(int n)
     {
         ArrayList<Integer> al=new ArrayList<>();
         int max=9;
         int res=0;
         while(n!=0){
             if(n>max){
                 al.add(max);
                 n-=max;
                 max--;
             }
            else{
                al.add(n);
                n=0;
            }

         }
         for(int i=al.size()-1;i>=0;i--){
             res=res*10+al.get(i);
         }
         System.out.println(res);
     }
 }
 public class mm{
     public static void main(String[] arg){
         Scanner sc=new Scanner(System.in);
         solution s=new solution();
         int t=sc.nextInt();
         while(t>0){
             int j=sc.nextInt();
             s.minval(j);
             j--;
         }
     }
 }


import java.util.Scanner;

public class ProblemC {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int result = solve(sc.nextInt());
            System.out.println(result);
        }
        sc.close();
    }

    private static int solve(int num) {
        StringBuilder sb = new StringBuilder();
        for (int j = 9; j >=1; j--) {
            if(num==0){
               break;
            }
            if(j<=num){
                sb.append(j);
                num -=j;
            }
        }
        return Integer.parseInt(sb.reverse().toString());
    }


import java.util.*;
import java.io.*;
import java.lang.*;
public class geeks
{
	public static void main(String[] args)
	{
        Scanner sc = new Scanner(System.in);
        String m = sc.next();
        int t =0;
        int q = sc.nextInt();
        if(m == 'January')
        {
            t=1;
        }
        else if(m == 'Feburary')
        {
            t =2;
        }
        else if(m == 'March')
        {
            t =3;
        }
        else if(m == 'April')
        {
            t =4;
        }
        else if(m == 'May')
        {
            t =5;
        }
        else if(m == 'June')
        {
            t =6;
        }
        else if(m == 'July')
        {
            t =7;
        }
        else if(m == 'August')
        {
            t =8;
        }
        else if(m == 'September')
        {
            t =9;
        }
        else if(m == 'October')
        {
            t =10;
        }
        else if(m == 'November')
        {
            t =11;
        }
        else if(m == 'December')
        {
            t =12;
        }
        t =t +q;
        t = t%12;
        if (t==0)
        {
            System.out.println("December");
        }
        else if(t==1)
        {
            System.out.println("January");
        }
        else if(t==2)
        {
            System.out.println("Feburary");
        }
        else if(t==3)
        {
            System.out.println("March");
        }
        else if(t==3)
        {
            System.out.println("April");
        }
        else if(t==4)
        {
            System.out.println("May");
        }
        else if(t==5)
        {
            System.out.println("June");
        }
        else if(t==6)
        {
            System.out.println("July");
        }
        else if(t==7)
        {
            System.out.println("August");
        }
        else if(t==8)
        {
            System.out.println("September");
        }
        else if(t==9)
        {
            System.out.println("October");
        }
        else if(t==10)
        {
            System.out.println("November");
        }
        else if(t==11)
        {
            System.out.println("December");
        }


import java.util.*;
import java.io.*;
import java.lang.*;
public class geeks
{
	public static void main(String[] args)
	{
        Scanner sc = new Scanner(System.in);
        String m = sc.next();
        int t =0;
        int q = sc.nextInt();
        if(m.compareTo("January")==0)
        {
            t=1;
        }
        else if(m.compareTo("February")==0)
        {
            t =2;
        }
        else if(m.compareTo("March")==0)
        {
            t =3;
        }
        else if(m.compareTo("April")==0)
        {
            t =4;
        }
        else if(m.compareTo("May")==0)
        {
            t =5;
        }
        else if(m.compareTo("June")==0)
        {
            t =6;
        }
        else if(m.compareTo("July")==0)
        {
            t =7;
        }
        else if(m.compareTo("August")==0)
        {
            t =8;
        }
        else if(m.compareTo("September")==0)
        {
            t =9;
        }
        else if(m.compareTo("October")==0)
        {
            t =10;
        }
        else if(m.compareTo("November")==0)
        {
            t =11;
        }
        else if(m.compareTo("December")==0)
        {
            t =12;
        }
        t =t +q;
        t = t%12;
        if (t==0)
        {
            System.out.println("December");
        }
        else if(t==1)
        {
            System.out.println("January");
        }
        else if(t==2)
        {
            System.out.println("February");
        }
        else if(t==3)
        {
            System.out.println("March");
        }
        else if(t==4)
        {
            System.out.println("April");
        }
        else if(t==5)
        {
            System.out.println("May");
        }
        else if(t==6)
        {
            System.out.println("June");
        }
        else if(t==7)
        {
            System.out.println("July");
        }
        else if(t==8)
        {
            System.out.println("August");
        }
        else if(t==9)
        {
            System.out.println("September");
        }
        else if(t==10)
        {
            System.out.println("October");
        }
        else if(t==11)
        {
            System.out.println("November");
        }
        sc.close;
	}
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class geeks
{
	public static void main(String[] args)
	{
        Scanner sc = new Scanner(System.in);
        String m = sc.next();
        int t =0;
        int q = sc.nextInt();
        if(m == "January")
        {
            t=1;
        }
        else if(m == 'Feburary')
        {
            t =2;
        }
        else if(m == 'March')
        {
            t =3;
        }
        else if(m == 'April')
        {
            t =4;
        }
        else if(m == 'May')
        {
            t =5;
        }
        else if(m == 'June')
        {
            t =6;
        }
        else if(m == 'July')
        {
            t =7;
        }
        else if(m == 'August')
        {
            t =8;
        }
        else if(m == 'September')
        {
            t =9;
        }
        else if(m == 'October')
        {
            t =10;
        }
        else if(m == 'November')
        {
            t =11;
        }
        else if(m == 'December')
        {
            t =12;
        }
        t =t +q;
        t = t%12;
        if (t==0)
        {
            System.out.println("December");
        }
        else if(t==1)
        {
            System.out.println("January");
        }
        else if(t==2)
        {
            System.out.println("Feburary");
        }
        else if(t==3)
        {
            System.out.println("March");
        }
        else if(t==3)
        {
            System.out.println("April");
        }
        else if(t==4)
        {
            System.out.println("May");
        }
        else if(t==5)
        {
            System.out.println("June");
        }
        else if(t==6)
        {
            System.out.println("July");
        }
        else if(t==7)
        {
            System.out.println("August");
        }
        else if(t==8)
        {
            System.out.println("September");
        }
        else if(t==9)
        {
            System.out.println("October");
        }
        else if(t==10)
        {
            System.out.println("November");
        }
        else if(t==11)
        {
            System.out.println("December");
        }


import java.util.*;
public class file{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
String str=scan.nextLine();
int a=scan.nextInt();
HashMap<String,Integer> map=new HashMap<>();
map.put("JANUARY",1);
map.put("FEBRUARY",2);
map.put("MARCH",3);
map.put("APRIL",4);
map.put("MAY",5);
map.put("JUNE",6);
map.put("JULY",7);
map.put("AUGUST",8);
map.put("SEPTEMBER",9);
map.put("OCTOBER",10);
map.put("NOVEMBER",11);
map.put("DECEMBER",0);
System.out.println(map.getKey(map.get(str)+a-1)%12);
}
}


import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int digits = ((n / 5) + "").length();

        int count = 0;
        for (int idx1 = 1, idx2 = 2; idx2 <= n && idx1 < idx2; ) {
            if ((idx1 + idx2) % getTen(digits) == getNine(digits)) {
                count++;
                idx1++;
                if (idx1 + 1 < idx2) {
                    idx2--;
                } else {
                    idx2++;
                }
            } else if (idx2 < n) {
                idx2++;
            } else {
                idx1++;
            }
        }
        System.out.println(count);
    }

    private int getTen(int digits) {
        StringBuilder sb = new StringBuilder("1");
        for (int i = 0; i < digits; i++) {
            sb.append("0");
        }
        return Integer.parseInt(sb.toString());
    }

    private int getNine(int digits) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < digits; i++) {
            sb.append("9");
        }
        return Integer.parseInt(sb.toString());
    }
}