There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs.

Visitors are more likely to buy a pair of shovels if their total cost ends with several 9s. Because of this, Polycarp wants to choose a pair of shovels to sell in such a way that the sum of their costs ends with maximum possible number of nines. For example, if he chooses shovels with costs 12345 and 37454, their total cost is 49799, it ends with two nines.

You are to compute the number of pairs of shovels such that their total cost ends with maximum possible number of nines. Two pairs are considered different if there is a shovel presented in one pair, but not in the other.

Input

The first line contains a single integer n (2 ≤ n ≤ 109) — the number of shovels in Polycarp's shop.

Output

Print the number of pairs of shovels such that their total cost ends with maximum possible number of nines. 

Note that it is possible that the largest number of 9s at the end is 0, then you should count all such ways.

It is guaranteed that for every n ≤ 109 the answer doesn't exceed 2·109.

Examples

Input

7


Output

3


Input

14


Output

9


Input

50


Output

1

Note

In the first example the maximum possible number of nines at the end is one. Polycarp cah choose the following pairs of shovels for that purpose:

  * 2 and 7; 
  * 3 and 6; 
  * 4 and 5. 



In the second example the maximum number of nines at the end of total cost of two shovels is one. The following pairs of shovels suit Polycarp:

  * 1 and 8; 
  * 2 and 7; 
  * 3 and 6; 
  * 4 and 5; 
  * 5 and 14; 
  * 6 and 13; 
  * 7 and 12; 
  * 8 and 11; 
  * 9 and 10. 



In the third example it is necessary to choose shovels 49 and 50, because the sum of their cost is 99, that means that the total number of nines is equal to two, which is maximum possible for n = 50.
//package math_codet;
//I got so many WA's in such a simple question _-_
import java.io.*;
import java.util.*;
 /******************************************
*    AUTHOR:         AMAN KUMAR SINGH        *
*    INSTITUITION:   KALYANI GOVERNMENT ENGINEERING COLLEGE  *
******************************************/
public class lets_do {
    InputReader in;
    PrintWriter out;
    Helper_class h;
    final long mod=1000000007;
    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new InputReader();
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t=1;
        while(t-->0)
            solve();
        out.flush();    
        out.close();
    }
    long n;
    long[] arr;
    HashMap<Integer,Integer> hmap=new HashMap<Integer,Integer>();
    TreeSet<Integer> hset=new TreeSet<Integer>();
    int cnt_digits(long z){
        int cnt=0;
        while(z>0){
            z=z/10;
            cnt++;
        }
        return cnt;
    }
    void solve(){
        n=h.nl();
        arr=new long[12];
        int i=0,j=0;;
        long sum=0;
        for(i=1;i<=11;i++){
            sum=(sum*10)+(long)9;
            arr[i]=sum;
        }
        int cnt=cnt_digits(n);
        boolean flag=false;
        for(i=cnt+1;i>=1 ;i--){
            if(arr[i]-n<n){
                long ans=0;
                int cnt_1=cnt_digits(arr[i]);
                long pow=(long)Math.pow(10,cnt_1);
                for(j=0;j<9;j++){
                    long sum1=(pow*j)+arr[i];
                    long x1=n;
                    long x2=sum1-n;
                    if(x2<x1){
                        if(x2<=0)
                            x2=1;
                        if(sum1<n)
                            x1=sum1-1;
                        ans+=(x1-x2+1)/2;
                    }
                }
                h.pn(ans);;
                flag=true;
                break;
            }
        }
        if(!flag)
            h.pn((n*(n-1))/2);
    }
    static final Comparator<Entity> com=new Comparator<Entity>(){
        public int compare(Entity a, Entity b){
            int xx=Integer.compare(a.x,b.x);
            if(xx==0)
                return Integer.compare(a.y,b.y);
            else
                return xx;
        }
    };
    class Entity{
        int x, y;
        Entity(int p, int q){
            x=p;
            y=q;
        }
    }
    class Helper_class{
        long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
        int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
        void p(Object o){out.print(o);}
        void pn(Object o){out.println(o);}
        void pni(Object o){out.println(o);out.flush();}
        String n(){return in.next();}
        String nln(){return in.nextLine();}
        int ni(){return Integer.parseInt(in.next());}
        long nl(){return Long.parseLong(in.next());}
        double nd(){return Double.parseDouble(in.next());}

        long mul(long a,long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            a*=b;
            if(a>=mod)a%=mod;
            return a;
        }
        long modPow(long a, long p){
            long o = 1;
            while(p>0){
                if((p&1)==1)o = mul(o,a);
                a = mul(a,a);
                p>>=1;
            }
            return o;
        }
        long add(long a, long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            if(b<0)b+=mod;
            a+=b;
            if(a>=mod)a-=mod;
            return a;
        }
    }

    class InputReader{
        BufferedReader br;
        StringTokenizer st;
        public InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public InputReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }
 
        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;
        }
    }
}       