import java.util.*;

public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型 */ public int findNthDigit (int n) { if(n == 0) return 0;

	long bottom = 1L;
    long top = 9L;
    long wei_bottom = bottom;
    long wei_top = top;
    int weishu = 1;
    if(n<=top && n>=bottom) {
    	return n;
    }else {
    	while(n > wei_top) {
    		weishu++;
    		bottom *= 10;
    		top = top*10 + 9;
    		wei_bottom = wei_top+1;
    		wei_top = (top-bottom+1) * weishu + wei_bottom - 1;
    	}
    	if(n < wei_top) {
    		long num = (n - wei_bottom) / weishu + bottom;
    		long yushu = (n - wei_bottom) % weishu;
    		int i = weishu - 1;
    		for(;i != yushu;i--) num = num / 10;
    		while(num >= 10) num = num % 10;
    		return (int)num;
    	}
    }
	
	return 0;
}

}