import java.util.*;
import java.math.*;
import java.lang.*;

public class Code {

	static Scanner sr = new Scanner(System.in);

	public static int[] getArray(int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++) {
			array[i] = sr.nextInt();
		}
		return array;
	}

	public static int[][] getMatrix(int sizeI, int sizeJ) {
		int[][] array = new int[sizeI][sizeJ];
		for (int i = 0; i < sizeI; i++) {
			for (int j = 0; j < sizeJ; j++) {
				array[i][j] = sr.nextInt();
			}
		}
		return array;
	}

	public static void main(String[] args) {

		int size = sr.nextInt();
		sr.nextLine();
		String input = sr.nextLine();
		int oneCount = 0;
		int zeroCount = 0;
		for (int i = 0; i < input.length(); i++) {
			if(input.charAt(i) == '1') oneCount++;
			else zeroCount++;
		}
		System.out.println(Math.abs(zeroCount - oneCount));
	}
}


import java.util.*;
import java.math.*;
import java.lang.*;

public class Code {

	static Scanner sr = new Scanner(System.in);

	public static int[] getArray(int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++) {
			array[i] = sr.nextInt();
		}
		return array;
	}

	public static int[][] getMatrix(int sizeI, int sizeJ) {
		int[][] array = new int[sizeI][sizeJ];
		for (int i = 0; i < sizeI; i++) {
			for (int j = 0; j < sizeJ; j++) {
				array[i][j] = sr.nextInt();
			}
		}
		return array;
	}

	public static void main(String[] args) {

		sr.nextLine();
		String input = sr.nextLine();

		for (int i = 0; i < 100; i++) {
			input = input.replace("01", "");
			input = input.replace("10", "");
		}
		System.out.println(input.length());
	}
}


public class MyClass {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num = scan.nextInt();
      String ch =  System.console().readLine();

      while ((ch.indexOf('1') != -1) && (ch.indexOf('0') != -1)){
        ch = ch.substring(0, ch.indexOf('1')) + ch.substring(ch.indexOf('1') + 1);
        ch = ch.substring(0, ch.indexOf('0')) + ch.substring(ch.indexOf('0') + 1);
      }

      num = ch.length();
      System.out.println(num);
  }
}


import java.util.Scanner;

public class A {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num = scan.nextInt();
      String ch = scan.next();
      //String ch =  System.console().readLine();

      while ((ch.indexOf('1') != -1) && (ch.indexOf('0') != -1)){
        ch = ch.substring(0, ch.indexOf('1')) + ch.substring(ch.indexOf('1') + 1);
        ch = ch.substring(0, ch.indexOf('0')) + ch.substring(ch.indexOf('0') + 1);
      }

      num = ch.length();
      System.out.println(num);
  }
}


import java.util.Scanner;

public class A {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num = scan.nextInt();
      String ch = scan.next();
      //String ch =  System.console().readLine();

      int one = 0;
      int zero = 0;
      for (int i=0; i<ch.length(); i++){
        if (ch.charAt(i) == '1'){
          one++;
        } else {
          zero++;
        }
      }

      num = Math.abs(one-zero);
      System.out.println(num);
  }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);  // Create a Scanner object
        String lengthStr = scannerObj.nextLine();
        int n = Integer.parseInt(lengthStr);
        //System.out.print("Length: "+length+"\n");

        String str = scannerObj.nextLine();
        //System.out.print(str+"\n");

        boolean a = str.contains("01");
        boolean b = str.contains("10");
        while (a || b){
            a = str.contains("01");
            b = str.contains("10");
            if (a){
                str = str.substring(0,str.indexOf("10"))+str.substring(str.indexOf("10")+2);
            }

            if (b){
                str = str.substring(0,str.indexOf("01")) + str.substring(str.indexOf("01")+2);
            }
        }

        System.out.print(str.length());
    }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);
        String n = scannerObj.nextLine();
        String str = scannerObj.nextLine();

        boolean a = str.contains("01");
        boolean b = str.contains("10");
        while (a || b){
            a = str.contains("01");
            b = str.contains("10");

            if (a){
                str = str.substring(0,str.indexOf("01")) + str.substring(str.indexOf("01")+2);
            } else if (b){
                str = str.substring(0,str.indexOf("10")) + str.substring(str.indexOf("10")+2);
            }
        }

        System.out.print(str.length());
    }
}


import java.util.Scanner;

public class MyClass {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num = scan.nextInt();
      String ch =  System.console().readLine();

      while ((ch.indexOf('1') != -1) && (ch.indexOf('0') != -1)){
        ch = ch.substring(0, ch.indexOf('1')) + ch.substring(ch.indexOf('1') + 1);
        ch = ch.substring(0, ch.indexOf('0')) + ch.substring(ch.indexOf('0') + 1);
      }

      num = ch.length();
      System.out.println(num);
  }
}


import java.util.Scanner;

public class S {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num = scan.nextInt();
      String ch =  System.console().readLine();

      while ((ch.indexOf('1') != -1) && (ch.indexOf('0') != -1)){
        ch = ch.substring(0, ch.indexOf('1')) + ch.substring(ch.indexOf('1') + 1);
        ch = ch.substring(0, ch.indexOf('0')) + ch.substring(ch.indexOf('0') + 1);
      }

      num = ch.length();
      System.out.println(num);
  }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);  // Create a Scanner object
        String lengthStr = scannerObj.nextLine();
        int n = Integer.parseInt(lengthStr);
        //System.out.print("Length: "+length+"\n");

        String str = scannerObj.nextLine();
        //System.out.print(str+"\n");

        boolean a = str.contains("01");
        boolean b = str.contains("10");
        while (a || b){
            a = str.contains("01");
            b = str.contains("10");

            if (a){
                str = str.substring(0,str.indexOf("01")) + str.substring(str.indexOf("01")+2);
            } else if (b){
                str = str.substring(0,str.indexOf("10")) + str.substring(str.indexOf("10")+2);
            }
        }

        System.out.print(str.length());
    }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);  // Create a Scanner object
        String n = scannerObj.nextLine();
        String str = scannerObj.nextLine();

        int a = str.indexOf("01");
        int b = str.indexOf("10");
        while (a != -1 || b != -1){
            a = str.indexOf("01");
            b = str.indexOf("10");

            if (a != -1){
                str = str.substring(0,a) + str.substring(a+2);
            } else if (b != -1){
                str = str.substring(0,b) + str.substring(b+2);
            }
        }

        System.out.print(str.length());
    }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);  // Create a Scanner object
        int n = scannerObj.nextInt();
        scannerObj.nextLine();
        String str = scannerObj.nextLine();

        int a = 0;
        int b = 0;

        for (int i=0; i<str.length(); i++){
            if (str.charAt(i) == '1'){
                a++;
            } else {
                b++;
            }
        }

        System.out.print(n-2*Integer.min(a,b));
    }
}


import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        Scanner scannerObj = new Scanner(System.in);  // Create a Scanner object
        String lengthStr = scannerObj.nextLine();
        int n = Integer.parseInt(lengthStr);
        //System.out.print("Length: "+length+"\n");

        String str = scannerObj.nextLine();
        //System.out.print(str+"\n");

        while (str.contains("01") || str.contains("10")){
            if (str.contains("10")){
                str = str.substring(0,str.indexOf("10"))+str.substring(str.indexOf("10")+2);
            } else if (str.contains("01")){
                str = str.substring(0,str.indexOf("01")) + str.substring(str.indexOf("01")+2);
            }
        }

        System.out.print(str.length());
    }
}


import java.util.ArrayList;
import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class CaseOfTheZerosAndOnes
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        String x=sc.next();

        String temp=x;
        while (true)
        {   char[]arr=temp.toCharArray();
            for (int i = 0; i < arr.length; i++)
            {
                if (i+1!=arr.length)
                {
                    String test=arr[i+1]+""+arr[i];
                    if (test.equals("01")||test.equals("10"))
                    {
                        arr[i]='2';arr[i+1]='2';i++;
                    }
                }
            }
            temp="";
            for (int i = 0; i < arr.length; i++)
            {
                if (arr[i]!='2')
                {
                    temp+=arr[i]+"";
                }
            }
            if (temp.contains("01")||temp.contains("10"))
            {
                continue;
            }
            else
                break;
        }
        System.out.println(temp.length());
    }

}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class NewClass
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();

        while (true)
        {
            x=x.replaceAll("10","");
            x=x.replaceAll("01","");
            if (x.contains("01")||x.contains("10"))
            {
                continue;
            }
            else
                break;
        }
        System.out.println(x.length());

    }
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class public class CaseOfTheZerosAndOnes
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();

        while (true)
        {
            x=x.replaceAll("10", "");
            x=x.replaceAll("01", "");
            if (x.contains("01")||x.contains("10"))
            {
                continue;
            }
            else
                break;
        }
        System.out.println(x.length());

    }
}


import com.sun.org.apache.bcel.internal.generic.AALOAD;
import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class public class CaseOfTheZerosAndOnes
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();

        while (true)
        {
            x=x.replaceAll("10", "");
            x=x.replaceAll("01", "");
            if (x.contains("01")||x.contains("10"))
            {
                continue;
            }
            else
                break;
        }
        System.out.println(x.length());

    }
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class NewClass
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();
        if (x.contains("10")||x.contains("01"))
        {
            while (true)
            {
                x=x.replaceAll("10","");
                x=x.replaceAll("01","");
                if (x.contains("01")||x.contains("10"))
                {
                    continue;
                }
                else
                    break;
            }
        }
        System.out.println(x.length());

    }
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class NewClass
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();
        if (x.contains("10")||x.contains("01"))
        {
            while (true)
            {
                if (x.contains("10"))
                {
                    x=x.replaceAll("10","");
                }
                if (x.contains("01"))
                {
                    x=x.replaceAll("01","");
                }
                if (x.contains("01")||x.contains("10"))
                {
                    continue;
                }
                else
                    break;
            }
        }
        System.out.println(x.length());

    }
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author Twins
 */
public class NewClass
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        sc.nextInt();
        String x=sc.next();
        int zero=0,one=0;
        for (int i = 0; i < x.length(); i++)
        {
            if (x.charAt(i)=='1')
            {
                one++;
            }
            else
                zero++;
        }
        System.out.println(Math.abs(one-zero));
    }
}


import java.util.Scanner;

public class CaseoftheZerosandOnes {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         String s = input.next();
         char[] c = s.toCharArray();
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
              for (int j = 0; j < c.length; j++) {
                  if (c[j]=='0'){
                    n-=2;
                    c[j]=2;
                    break;
                  }
              }
          }
         }
         System.out.println(n);
    }

}


import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
        }
    }

}


import java.util.Scanner;

public class Stringtest {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         int c0 = n;
         String s = input.next();
         char[] c = s.toCharArray();
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
           c1++;
          }
         }
         c0-=c1;
         int min = Math.min(c0, c1);
         n-=min*2;
         System.out.println(n);
    }

}


import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         if(c.length == n){
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
         }
        }
    }

}


/*
 * 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 stringtest;

import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        while (input.hasNext()) {
         int n = input.nextInt();
         String s = input.next();
         char[] c = s.toCharArray();
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             for (int j = 0; j < c.length; j++) {
                 if(c[j]=='0'){
                  n -= 2;
                  c[j]='1';
                  break;
                 }
             }
          }
         }
         System.out.println(n);
        }
    }

}


/*
 * 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.
 */

import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         if(c.length == n){
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
        }
    }

}


/*
 * 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 stringtest;

import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Stringtest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
              for (int j = 0; j < c.length; j++) {
                  if (c[j]=='0'){
                    n-=2;
                    c[j]=2;
                    break;
                  }
              }
          }
         }
         System.out.println(n);
    }

}


import java.util.Scanner;
public class CaseoftheZerosandOnes {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         if(c.length == n){
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
         }
        }
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNext()) {
         int n = input.nextInt();
         String s = input.next();
         char[] c = s.toCharArray();
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             for (int j = 0; j < c.length; j++) {
                 if(c[j]=='0'){
                  n -= 2;
                  c[j]='1';
                  break;
                 }
             }
          }
         }
         System.out.println(n);
        }
    }

}


/*
 * 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 stringtest;

import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Stringtest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         if(c.length == n){
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
         }
        }
    }

}


/*
 * 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 stringtest;

import java.util.Scanner;

/**
 *
 * @author M.A.Alian
 */
public class Stringtest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         if(c.length == n){
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
         }
    }

}


import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
         int n = input.nextInt();
         int r = n;
         String s = input.next();
         char[] c = s.toCharArray();
         int c1 = 0;
         for (int i = 0; i < c.length; i++) {
          if(c[i]=='1'){
             c1++;
          }
         }
         r -= c1;
         if(r>0){
         n-=r*2;
         }
         System.out.println(n);
        }
    }

}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        while (a.matches("(.*01.*|.*10.*)")) {
            a = a.replaceAll("(01|10)", "");

        }
        System.out.println(a.length());

    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        do {
            for (int i = 0; i < a.length() - 1; i++) {
                if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                        || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                    a = remove(a, i, i + 1);
                }
            }
        } while (!check(a));

        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        return s.substring(0, start) + s.substring(end + 1);
    }

    public static boolean check(String a) {
        for (int i = 0; i < a.length() - 1; i++) {
            if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                    || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                return false;
            }
        }
        return true;
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        do {
            for (int i = 0; i < a.length() - 1; i++) {
                if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                        || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                    a = remove(a, i, i + 1);
                }
            }
        } while (!check(a));
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        return s.substring(0, start) + s.substring(end + 1);
    }

    public static boolean check(String a) {
        for (int i = 0; i < a.length() - 1; i++) {
            if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                    || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                return false;
            }
        }
        return true;
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int zeros = 0, ones = 0;
        in.nextLine();
        String a = in.nextLine();
        for (int i = 0; i < n; i++) {
            if (a.charAt(i) == '0') {
                zeros++;
            } else {
                ones++;
            }
        }

        System.out.println(zeros > ones ? zeros - ones : ones - zeros);

    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static int index;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        while (check(a) != -1) {
            a = remove(a, index, index + 1);
        }
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        String s1 = s.substring(0, start) + s.substring(end + 1);
        return s1;
    }

    public static int check(String a) {
        for (int i = 0; i < a.length() - 1; i++) {
            if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                    || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                index = i;
                return i;
            }
        }
        return -1;
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        while (!check(a)) {
            for (int i = 0; i < a.length() - 1; i++) {
                if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                        || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                    a = remove(a, i, i + 1);
                }
            }
        }
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        return s.substring(0, start) + s.substring(end + 1);
    }

    public static boolean check(String a) {
        for (int i = 0; i < a.length() - 1; i++) {
            if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                    || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                return false;
            }
        }
        return true;
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        while (a.matches("(.*01.*|.*10.*)")) {
            for (int i = 0; i < a.length() - 1; i++) {
                if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                        || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                    a = remove(a, i, i + 1);
                }
            }
        }
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        return s.substring(0, start) + s.substring(end + 1);
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        while (check(a) != -1) {
            int i = check(a);
            a = remove(a, i, i + 1);
        }
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        String s1 = s.substring(0, start) + s.substring(end + 1);
        return s1;
    }

    public static int check(String a) {
        for (int i = 0; i < a.length() - 1; i++) {
            if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                    || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                return i;
            }
        }
        return -1;
    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        String a = in.nextLine();
        for (int j = 0; j < n / 2; j++) {
            a = a.replaceAll("(01|10)", "");
        }
        System.out.println(a.length());

    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String a = in.nextLine();
        a = a.replaceAll("(01|10)", "");

        System.out.println(a.length());

    }
}


import java.util.Scanner;

/**
 *
 * @author aboRagab
 */
public class ACaseOfTheZerosAndOnes {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        String a = in.nextLine();
        for (int j = 0; j < n / 2; j++) {
            for (int i = 0; i < a.length() - 1; i++) {
                if ((a.charAt(i) == '0' && a.charAt(i + 1) == '1')
                        || (a.charAt(i) == '1' && a.charAt(i + 1) == '0')) {
                    a = remove(a, i, i + 1);
                }
            }
        }
        System.out.println(a.length());

    }

    public static String remove(String s, int start, int end) {
        return s.substring(0, start) + s.substring(end + 1);
    }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            String n=sc.nextLine();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }

            int result=Math.abs((zero-one));
            System.out.println(result);
      }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }
            int result=Math.abs((zero-one));
            System.out.println(result1);
      }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }
            System.out.println(zero+" "+one);
            int result=Math.abs((zero-one));
            System.out.println(result);
      }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }
            System.out.println(Math.abs(zero-one));

      }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }
            System.out.println(Math.abs((zero-one));

      }
}


import java.util.*;
public class sol{
      public static void main(String[] args ){
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            String s=sc.nextLine();
            int zero=0;
            int one=0;
            for(char c : s.toCharArray()){
                  if(c=='0')
                  zero++;
                  else one++;
            }
            int result=Math.abs((zero-one));
            System.out.println(result);
      }
}


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

public class sd
{

    public static void main(String [] args) throws IOException
    {
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
       String line = in.readLine();
       String[] q = (line.split(" "));
       int l = Integer.parseInt(q[0]);
       String a = q[1];

       ArrayList<String> n = new ArrayList<String>();
       boolean noMore = false;
       for (int i=0; i<l; i++)
       {
           n.add(a.substring(i, i+1));
        }

       int x=0;
       int y=1;
       if (n.size() <2)
       {
           System.out.println(n.size());
           noMore = true;
       }
       else
       {
       while (!noMore)
       {
           if (n.size() <2)
           {
               noMore = true;

            }
           else
           {
           if (n.get(x).equals("0"))
           {
                if (n.get(y).equals("1"))
                {
                    n.remove(x);
                    n.remove(x);
                    x=0;
                    y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }
           else if (n.get(x).equals("1"))
           {
               if (n.get(y).equals("0"))
               {
                   n.remove(x);
                   n.remove(x);
                   x=0;
                   y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }

    }
}
    System.out.println(n.size());
}
       in.close();
    }
}


import java.util.*;
public class sd
{

    public static void main(String [] args)
    {
       Scanner in = new Scanner(System.in);
       int l = in.nextInt();
       String a = in.next();
       ArrayList<String> n = new ArrayList<String>();
       boolean noMore = false;
       for (int i=0; i<l; i++)
       {
           n.add(a.substring(i, i+1));
        }

       int x=0;
       int y=1;
       if (n.size() <2)
       {
           System.out.println(n.size());
           noMore = true;
       }
       else
       {
       while (!noMore)
       {
           if (n.size() <2)
           {
               noMore = true;

            }
           else
           {
           if (n.get(x).equals("0"))
           {
                if (n.get(y).equals("1"))
                {
                    n.remove(x);
                    n.remove(x);
                    x=0;
                    y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }
           else if (n.get(x).equals("1"))
           {
               if (n.get(y).equals("0"))
               {
                   n.remove(x);
                   n.remove(x);
                   x=0;
                   y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }

    }
}
System.out.println(n.size());
}
       in.close();
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class asd
{
    public static void main(String [] args) throws IOException
    {
        Reader.init(System.in);
        int N = Reader.nextInt();

        Stack<Character> input= new Stack<Character>();
        String next = Reader.next();
        for (int i=0; i<N; i++)
        {
            char in = next.charAt(i);
            if (input.isEmpty())
            {
                input.push(in);
            }
            else if (in == input.peek())
            {
                input.push(in);
            }
            else
            {
                input.pop();
            }
        }
        System.out.println(input.size());

    }
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

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

}


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

public class sd
{

    public static void main(String [] args) throws IOException
    {
       Reader.init(System.in);

       int l = Reader.nextInt();

       String a = Reader.next();

       ArrayList<String> n = new ArrayList<String>();
       boolean noMore = false;
       for (int i=0; i<l; i++)
       {
           n.add(a.substring(i, i+1));
        }

       int x=0;
       int y=1;

       while (!noMore)
       {
           if (n.size() <2)
           {
               noMore = true;

            }
           else
           {
           if (n.get(x).equals("0"))
           {
                if (n.get(y).equals("1"))
                {
                    n.remove(x);
                    n.remove(x);
                    x=0;
                    y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }
           else if (n.get(x).equals("1"))
           {
               if (n.get(y).equals("0"))
               {
                   n.remove(x);
                   n.remove(x);
                   x=0;
                   y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }

    }
}
    System.out.println(n.size());

    }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

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


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

public class sd
{

    public static void main(String [] args) throws IOException
    {
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
       String line = in.readLine();
       String[] q = (line.split(" "));
       int l = Integer.parseInt(q[0]);
       String a = q[1];

       ArrayList<String> n = new ArrayList<String>();
       boolean noMore = false;
       for (int i=0; i<l; i++)
       {
           n.add(a.substring(i, i+1));
        }

       int x=0;
       int y=1;
       if (n.size() <2)
       {
           System.out.println(n.size());
           noMore = true;
       }
       else
       {
       while (!noMore)
       {
           if (n.size() <2)
           {
               noMore = true;

            }
           else
           {
           if (n.get(x).equals("0"))
           {
                if (n.get(y).equals("1"))
                {
                    n.remove(x);
                    n.remove(x);
                    x=0;
                    y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }
           else if (n.get(x).equals("1"))
           {
               if (n.get(y).equals("0"))
               {
                   n.remove(x);
                   n.remove(x);
                   x=0;
                   y=1;
                }
                else
           {
               x++;
               y++;
               if(y == n.size())
               {
                   noMore = true;
                }

           }
           }

    }
}
    System.out.println(n.size());
}
       in.close();
    }
}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];
long long ex[61];
int main(void)
{
    map<long long, long long> has;
    int n;
    long long k;
    long long ans=0;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    int check=0;
    if(k!=1&&k!=-1)
    for(int i=1;i<=50;i++)
    {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1e15)
        {
            check=i;
            break;
        }
    }
    has[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>tot;
        sum[i]=sum[i-1]+tot;
        has[sum[i]]++;
    }
    for(int i=0;i<=n;i++)
    {
        if(k==1)
        {
            ans=ans+has[sum[i]+1];
            has[sum[i]]--;
        }
        else
        if(k==-1)
        {
            ans=ans+has[sum[i]+1]+has[sum[i]-1];
            has[sum[i]]--;
        }
        else
        {
            for(int j=1;j<=check;j++)
                ans=ans+has[sum[i]+ex[j]];
            has[sum[i]]--;
        }

    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long arr[10000000];
long long sum[10000000];
long long check[11];
//int ans[11];
int main(void)
{
    int n,ans=0;
    long long k;
    long long v;
    cin>>n>>k;
    int p=1;
    for(int i=1;i<=60;i++)
    {
        p=p*k;
        check[i]=p;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        int k=i;
        while(k<=n)
        {
            arr[k]=arr[k]+v;
            k=k+(k&-k);
        }
    }
    for(int i=1;i<=n;i++)
    {
        int k=i;
        int s=0;
        while(k>0)
        {
            s=s+arr[k];
            k=k-(k&-k);
        }
        sum[i]=s;
    }

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            long long t;
            t=sum[j]-sum[i];
            int cou=0;
            for(int i=1;i<=10;i++)
            {
                if(check[i]>t)
                    break;
                else
                {
                    if(check[i]==t)
                    {
                        cou++;
                        break;
                    }
                }
            }

             if(cou)
             {
                 ans++;
                 //cout<<i<<" "<<j<<endl;
             }

        }
    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long arr[10000000];
long long sum[10000000];
int check[11];
//int ans[11];
int main(void)
{
    int n,ans=0;
    long long k;
    long long v;
    cin>>n>>k;
    int p=1;
    for(int i=1;i<=10;i++)
    {
        p=p*k;
        check[i]=p;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        int k=i;
        while(k<=n)
        {
            arr[k]=arr[k]+v;
            k=k+(k&-k);
        }
    }
    for(int i=1;i<=n;i++)
    {
        int k=i;
        int s=0;
        while(k>0)
        {
            s=s+arr[k];
            k=k-(k&-k);
        }
        sum[i]=s;
    }

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            long long t;
            t=sum[j]-sum[i];
            int cou=0;
            for(int i=1;i<=10;i++)
            {
                if(check[i]>t)
                    break;
                else
                {
                    if(check[i]==t)
                    {
                        cou++;
                        break;
                    }
                }
            }

             if(cou)
             {
                 ans++;
                 //cout<<i<<" "<<j<<endl;
             }

        }
    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];

int main(void)
{
    int n,ans=0;
    long long k;
    long long v;
    cin>>n>>k;
    long long tot=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        tot=tot+v;
        sum[i]=sum[i]+tot;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            long long t;
            t=sum[j]-sum[i];
            int cou=0;
            while(t)
            {
                if(t%k==0)
                {
                    t=t/k;
                    if(t==1)
                    {
                        cou++;
                        break;
                    }
                }
                else
                    break;
            }

             if(cou)
             ans++;

        }
    }
    cout<<ans;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];
long long ex[61];
int main(void)
{
    map<long long, int> has;
    int n,ans=0;
    long long k;
    long long v;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    if(k!=1&&k!=-1)
    for(int i=1;i<=50;i++)
    {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1000000000000000)
            break;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        tot=tot+v;
        sum[i]=sum[i]+tot;
        has[sum[i]]++;
    }
    sum[0]=0;
    for(int i=0;i<=n;i++)
    {
        if(k==1)
        {
            ans=ans+has[sum[i]+1];
            has[sum[i]]--;
        }
        else
        if(k==-1)
        {
            ans=ans+has[sum[i]+1]+has[sum[i]-1];
            has[sum[i]]--;
        }
        else
        {
            for(int j=1;j<=50;j++)
                ans=ans+has[sum[i]+ex[j]];
            has[sum[i]]--;
        }

    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];
long long ex[61];
int main(void)
{
    map<long long, int> has;
    int n,ans=0;
    long long k;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    int check=0;
    if(k!=1&&k!=-1)
    for(int i=1;i<=50;i++)
    {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1000000000000000)
        {
            check=i;
            break;
        }
    }
    has[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>tot;
        sum[i]=sum[i-1]+tot;
        has[sum[i]]++;
    }
    for(int i=0;i<=n;i++)
    {
        if(k==1)
        {
            ans=ans+has[sum[i]+1];
            has[sum[i]]--;
        }
        else
        if(k==-1)
        {
            ans=ans+has[sum[i]+1]+has[sum[i]-1];
            has[sum[i]]--;
        }
        else
        {
            for(int j=1;j<=check;j++)
                ans=ans+has[sum[i]+ex[j]];
            has[sum[i]]--;
        }

    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long ex[61];
int main(void)
{
    map<long long, long long> has;
    int n;
    long long k;
    long long ans=0;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    int check=0;
    if(k!=1&&k!=-1)
    {
        for(int i=1;i<=50;i++)
       {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1e15||ori<-1e15)
        {
            check=i;
            break;
        }
       }
    }
    long long temp=0;
    has[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>tot;
        temp=temp+tot;

        if(k==1)
        ans=ans+has[temp-1];
        else
        if(k==-1)
        ans=ans+has[temp+1]+has[temp-1];
        else
        {
            for(int j=1;j<=check;j++)
            ans=ans+has[temp-ex[j]];
            ans=ans+has[temp-1];
        }
        has[temp]++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];
long long ex[61];
int main(void)
{
    map<long long, int> has;
    int n;
    long long k;
    long long ans=0;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    int check=0;
    if(k!=1&&k!=-1)
    for(int i=1;i<=50;i++)
    {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1e15||ori<-1e15)
        {
            check=i;
            break;
        }
    }
    has[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>tot;
        sum[i]=sum[i-1]+tot;
        has[sum[i]]++;
    }
    for(int i=0;i<=n;i++)
    {
        if(k==1)
        {
            ans=ans+has[sum[i]+1];
            has[sum[i]]--;
        }
        else
        if(k==-1)
        {
            ans=ans+has[sum[i]+1]+has[sum[i]-1];
            has[sum[i]]--;
        }
        else
        {
            for(int j=1;j<=check;j++)
                ans=ans+has[sum[i]+ex[j]];
            has[sum[i]]--;
        }

    }
    cout<<ans;

}


#include<bits/stdc++.h>

using namespace std;
long long sum[1000000];
long long ex[61];
int main(void)
{
    map<long long, long long> has;
    int n;
    long long k;
    long long ans=0;
    cin>>n>>k;
    long long tot=0;
    long long ori=1;
    int check=0;
    if(k!=1&&k!=-1)
    {
        for(int i=1;i<=50;i++)
       {
        ori=ori*k;
        ex[i]=ori;
        if(ori>=1e15||ori<-1e15)
        {
            check=i;
            break;
        }
       }
    }

    has[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>tot;
        sum[i]=sum[i-1]+tot;

        if(k==1)
        ans=ans+has[sum[i]-1];
        else
        if(k==-1)
        ans=ans+has[sum[i]+1]+has[sum[i]-1];
        else
        {
            for(int j=1;j<=check;j++)
            ans=ans+has[sum[i]-ex[j]];
        }
        has[sum[i]]++;
    }
    cout<<ans;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF,p<=100;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1;j<=INF;j*=k) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    scanf("%d %lld",&n,&k);
        x.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF&&p<=60;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        x.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            int p=0;
            for(LL j=1;j<=INF;j*=k)
            {
                if(p>60) break;
                p++;
                ans+=x[sum[i]-j];
            }
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;
set<LL>a;
set<LL>::iterator it;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        a.clear();
        x.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        a.insert(1);
        LL temp=k;
        while(temp<=INF) a.insert(temp),temp*=k;
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(it=a.begin();it!=a.end();it++) ans+=x[sum[i]-*it];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        x.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF&&p<=60;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;
set<LL>a;
set<LL>::iterator it;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        x.clear();
        a.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        a.insert(1);
        LL temp=k;
        for(int i=1;i<=60;i++)
        {
            if(temp>INF) break;
            a.insert(temp);
            temp*=k;
        }
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(it=a.begin();it!=a.end();it++) ans+=x[sum[i]-*it];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        x.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF&&p<=100;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;
set<LL>a;
set<LL>::iterator it;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        a.insert(1);
        LL temp=k;
        while(temp<=INF) a.insert(temp),temp*=k;
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(it=a.begin();it!=a.end();it++) ans+=x[sum[i]-*it];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF,p<=100;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1,p=0;j<=INF&&p<=100;j*=k,p++) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const LL INF=1e14;

int n;
LL k,sum[100050];
map<LL,LL>x;

int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++) scanf("%lld",&sum[i]),sum[i]+=sum[i-1];
        LL ans=0;
        x[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(LL j=1;j<=INF;j*=k) ans+=x[sum[i]-j];
            x[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	ll n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		ll j = 1;
		for (int lel = 0; lel <= 15; lel++) {
			ll cari = sum-j;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];

			j *= k;
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		if (k == 1) {
			ll cari = sum-1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		} else if (k == -1) {
			ll cari = sum-1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];

			cari = sum+1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		} else {
			for (ll j = 1; j <= MAX; j*=k) {
				ll cari = sum-j;

				if (freq.find(cari) != freq.end())
					ans += freq[cari];
			}
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		if (abs(k) == 1) {
			ll cari = sum-1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];

			cari = sum+1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		} else {
			for (ll j = 1; j <= MAX; j*=k) {
				ll cari = sum-j;

				if (freq.find(cari) != freq.end())
					ans += freq[cari];
			}
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		for (ll j = 1; j <= MAX; j*=k) {
			ll cari = sum-j;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		if (k == 1) {
			ll cari = sum-1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		} else {
			for (ll j = 1; j <= MAX; j*=k) {
				ll cari = sum-j;

				if (freq.find(cari) != freq.end())
					ans += freq[cari];
			}
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		ll j = 1;
		for (ll z = 1; z <= (k == 1 ?  1 : 14); z++) {
			ll cari = sum-j;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
			j *= k;
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

const ll MAX = 1e15;

int main() {
	int n, k;
	cin >> n >> k;

	map<ll, int> freq;

	freq[0] = 1;

	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;

		sum += x;

		if (abs(k) == 1) {
			ll cari = sum-1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];

			ll cari = sum+1;

			if (freq.find(cari) != freq.end())
				ans += freq[cari];
		} else {
			for (ll j = 1; j <= MAX; j*=k) {
				ll cari = sum-j;

				if (freq.find(cari) != freq.end())
					ans += freq[cari];
			}
		}

		freq[sum] += 1;
	}

	cout << ans << endl;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[300000], add[300000], pow[1000], maxn;
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        ans += m[add[i+1]-a];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;

        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
                solve(-1);
        }
        else
        {
            for(maxn = 1; pow[maxn-1] < 1e15 + 10; maxn++)
            {
                pow[maxn] = k*pow[maxn-1];
            }
            for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[300000], add[300000], pow[1000], maxn;
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1]-a);
        if(it != m.end())
            ans += it->second;
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
                solve(-1);
        }
        else
        {
            for(maxn = 1; pow[maxn-1] < 1e15 + 10; maxn++)
            {
                pow[maxn] = k*pow[maxn-1];
            }
            for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[3000], add[3000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1] - a);
        if(it != m.end())
            ans += it->second;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            for(int i = 1; i <= n; i++)
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1] - a);
        if(it != m.end())
            ans += it->second;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<stdio.h>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        //it = m.find(add[i+1] - a);
        //if(it != m.end())
            //ans += it->second;
        ans += m[add[i+1]-a];
    }
}

int main()
{
    //std::ios::sync_with_stdio(false);
    while(scanf("%ld %ld", &n, &k))
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            scanf("%ld",&a[i]);
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                solve(j);
        }
        printf("%ld\n",ans);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000], pow[100], maxn;
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1]-a);
        if(it != m.end())
            ans += it->second;
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;
        if(k != 1 && k != -1)
        for(maxn = 1; pow[maxn-1] < 1e14 + 10; maxn++)
        {
            pow[maxn] = k*pow[maxn-1];
        }

        /*for(int i = 0; i < maxn; i++)
        {
            cout << pow[i] << ' ';
        }
        cout << endl;*/
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else if(k == 0)
        {
            solve(0);
        }
        else
        {
             for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1] - a);
        if(it != m.end())
            ans += it->second;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            for(int i = 1; i <= n; i++)
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[300000], add[300000], pow[100], maxn;
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1]-a);
        if(it != m.end())
            ans += it->second;
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;
        if(k != 1 && k != -1)
            for(maxn = 1; pow[maxn-1] < 1e15 + 10; maxn++)
            {
                pow[maxn] = k*pow[maxn-1];
            }

        /*for(int i = 0; i < maxn; i++)
        {
            cout << pow[i] << ' ';
        }
        cout << endl;*/
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else if(k == 0)
        {
            solve(0);
        }
        else
        {
             for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        //it = m.find(add[i+1] - a);
        //if(it != m.end())
            //ans += it->second;
        ans += m[add[i+1]-a];
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        ans += m[add[i+1]-a];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j <= 1e14 + 10; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1]-a);
        if(it != m.end())
            ans += it->second;
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j <= 1e14 + 10; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000];
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        ans += m[add[i+1]-a];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j <= 1e15; j = j * k)
                solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[300000], add[300000], pow[1000], maxn;
map<long long, long long>::iterator it;
void solve(long long a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        ans += m[add[i+1]-a];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(maxn = 1; pow[maxn-1] < 1e15 + 10; maxn++)
                pow[maxn] = k*pow[maxn-1];
            for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[3000], add[3000];
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1] - a);
        if(it != m.end())
            ans += it->second;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);

    while(cin >> n >> k)
    {
        ans = 0;
        for(int i = 0; i < n; i++)
            cin >> a[i];
        map<long long, long long> m;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
            add[i] = add[i-1] + a[i - 1];
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else
        {
            for(long long j = 1; j < 1e15 + 100; j = j * k)
                    solve(j);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
long long n, k;
long long ans;
long long a[30000], add[30000], pow[100], maxn;
map<long long, long long>::iterator it;
void solve(int a)
{
    map<long long, long long> m;
    for(int i = 0; i < n; i++)
    {
        m[add[i]]++;
        it = m.find(add[i+1]-a);
        if(it != m.end())
            ans += it->second;
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin >> n >> k)
    {
        ans = 0;
        add[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            add[i] = add[i-1] + a[i];
        }
        pow[0] = 1;
        if(k != 1 && k != -1)
            for(maxn = 1; pow[maxn-1] < 1e15 + 10; maxn++)
            {
                pow[maxn] = k*pow[maxn-1];
            }

        /*for(int i = 0; i < maxn; i++)
        {
            cout << pow[i] << ' ';
        }
        cout << endl;*/
        if(k == 1 || k == -1)
        {
            solve(1);
            if(k == -1)
            solve(-1);
        }
        else if(k == 0)
        {
            solve(0);
        }
        else
        {
             for(int i = 0; i < maxn; i++)
                solve(pow[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(1e5+50)
map<ll,int> ma;
int a[N];
ll pref[N];
ll mx=1e15;
ll mAx=-1e15;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sd(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
        mAx=max(mAx,pref[i]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1){
            ans+=ma[k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;abs(pw)<=abs(mAx);pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(4e5+50)
map<ll,int> ma;
ll a[N],pref[N];
ll mx=1e16;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sl(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1){
            ans+=ma[k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;abs(pw)<=mx;pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(1e5+50)
map<ll,int> ma;
int a[N];
ll pref[N];
ll mx=1e15;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sd(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1||k==-1){
            ans+=ma[k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;abs(pw)<=mx;pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(4e5+50)
map<ll,int> ma;
ll a[N],pref[N];
ll mx=1e17;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sl(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1){
            ans+=ma[k-pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;pw<=mx;pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(1e5+50)
map<ll,int> ma;
int a[N];
ll pref[N];
ll mx=1e15;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sd(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1){
            ans+=ma[k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        if(k==-1){
            ans+=ma[k+pref[i-1]];
            ans+=ma[-k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;abs(pw)<=mx;pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d",x)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)(1e5+50)
map<ll,int> ma;
int a[N];
ll pref[N];
ll mx=1e15;
void solve(){
    int n;ll k;
    sd(n);sl(k);
    for(int i=1;i<=n;i++){
        sd(a[i]);
        pref[i]=pref[i-1]+a[i];
        ma[pref[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(k==1){
            ans+=ma[k+pref[i-1]];
            ma[pref[i]]--;
            continue;
        }
        ll pw=1;
        for(;abs(pw)<=mx;pw*=k){
            ans+=ma[pw+pref[i-1]];
        }
        ma[pref[i]]--;
    }
    pl(ans);
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(0);
    int t=1;
    //sd(t);
    for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <fstream>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include<climits>
#include <ctime>

//#define DISPLAYTIME

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)

#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)

#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)

#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)

#define REP_S(it, str) for (char*it=str;*it;++it)
#define REP_G(it, u) for (int it=hd[u];it;it=suc[it])

#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())

#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define P(T) pair<T, T>
#define Pint pair<int, int>
#define fi first
#define se second
#define D(v) (cout << #v << " is equal to " << v << endl)
#define DP(v) (cout << #v << " is equal to " << v.fi << " " << v.se << endl)
#define ZERO(v) memset(v,0,sizeof(v))
#define MIO(v) memset(v,-1,sizeof(v))
const int maxn = 1e5 + 7;
LL a[maxn], f[maxn];
int n, k;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    //freopen("o.txt","w",stdout);
#ifdef DISPLAYTIME
    clock_t start, end;
    start = clock();
#endif
#endif

#ifndef LOCAL
    std::ios::sync_with_stdio(false);
#endif
    cin >> n >> k;
    REP_1(i, n) {
        cin >> a[i];
    }
    REP_1(i, n) {
        f[i] = f[i - 1] + a[i];
    }
    ULL cur = 1;
    vector<ULL> v;
    LL cnt = 0;
    map<LL, int> m;
    if(k == 1) {
        for(int i = n; i >= 0; i--) {
            cnt += m[f[i] + 1];
            m[f[i]]++;
        }
    } else if(k == -1) {
        for(int i = n; i >= 0; i--) {
            cnt += m[f[i] + 1];
            cnt += m[f[i] - 1];
            m[f[i]]++;
        }
    } else {
        REP(i, 50) {
            v.PB(cur);
            cur *= k;
        }
        for(int i = n; i >= 0; i--) {
            REP(j, SZ(v)) {
                cnt += m[f[i] + v[j]];
            }
            m[f[i]]++;
        }
    }
    cout << cnt << endl;

#ifdef DISPLAYTIME
#ifdef LOCAL
    end = clock();
    cout << "*************************" << endl;
    cout << "Computing time: " << (double)(end - start) * 1000 / CLOCKS_PER_SEC << "ms" << endl;
#endif
#endif
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <fstream>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include<climits>
#include <ctime>

//#define DISPLAYTIME

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)

#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)

#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)

#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)

#define REP_S(it, str) for (char*it=str;*it;++it)
#define REP_G(it, u) for (int it=hd[u];it;it=suc[it])

#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())

#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define P(T) pair<T, T>
#define Pint pair<int, int>
#define fi first
#define se second
#define D(v) (cout << #v << " is equal to " << v << endl)
#define DP(v) (cout << #v << " is equal to " << v.fi << " " << v.se << endl)
#define ZERO(v) memset(v,0,sizeof(v))
#define MIO(v) memset(v,-1,sizeof(v))
const int maxn = 1e5 + 7;
LL a[maxn], f[maxn];

int n, k;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    //freopen("o.txt","w",stdout);
#ifdef DISPLAYTIME
    clock_t start, end;
    start = clock();
#endif
#endif

#ifndef LOCAL
    std::ios::sync_with_stdio(false);
#endif

    cin >> n >> k;
    REP_1(i, n) {
        cin >> a[i];
    }
    REP_1(i, n) {
        f[i] = f[i - 1] + a[i];
    }

    LL cur = 1;
    vector<LL> v;

    int cnt = 0;
    map<LL, int> m;
    if(k == 1) {
        for(int i = n; i >= 0; i--) {
            cnt += m[f[i] + 1];
            m[f[i]]++;
        }
    } else if(k == -1) {
        v.PB(1);
        v.PB(-1);
        for(int i = n; i >= 0; i--) {
            cnt += m[f[i] + 1];
            cnt += m[f[i] - 1];
            m[f[i]]++;
        }
    } else {
        REP(i, 50) {
            v.PB(cur);
            cur *= k;
        }
        sort(ALL(v));
        for(int i = n; i >= 0; i--) {
            REP(j, SZ(v)) {
                if(m[f[i] + v[j]]) {
                    cnt++;
                }
            }
            m[f[i]]++;
        }
    }
    cout << cnt << endl;

#ifdef DISPLAYTIME
#ifdef LOCAL
    end = clock();
    cout << "*************************" << endl;
    cout << "Computing time: " << (double)(end - start) * 1000 / CLOCKS_PER_SEC << "ms" << endl;
#endif
#endif
    return 0;
}