Binary to Decimal Conversion

import java.util.Scanner;
class Main
{
    public static void bintoDec()
    {
    System.out.println("enter a number to convert binary to decimal ");
    Scanner sc = new Scanner(System.in);    
    int N = sc.nextInt();
    int ans=0;
    int p=1;
    while(N!=0)
    {
        ans=ans+(N%10)*p;
        p=p*2;
        N=N/10;
    }
    System.out.println(ans);    
    }
    public static void main(String args[])
    {
        bintoDec();
    }
}

i/p:1101

enter a number to convert binary to decimal 
13