#include<stdio.h>
int a[100];
int nn(int p,int q)
{
    int i;
    for(i=p+1; i<q; i++)
        if(a[i]<a[i-1])
            return 0;
    return 1;
}
int main()
{
    int n,max=0,i,m;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(nn(0,n))
    {
        printf("%d",n);
        return 0;
    }
    else if(n==2)
    {
        printf("%d",n/2);
        return 0;
    }
    else if(n==4)
    {
        if(nn(0,2))
            printf("%d",n/2);
        else if(nn(2,4))
            printf("%d",n/2);
        else
            printf("1");

    }
    else if(n==8)
    {
        if(nn(0,4))
            printf("%d",n/2);
        else if(nn(4,8))
            printf("%d",n/2);
        else
        {
            if(nn(0,2))
                printf("2");
            else if(nn(2,4))
                printf("2");
            else if(nn(4,6))
                printf("2");
            else if(nn(6,8))
                printf("2");
            else
                printf("1");
        }
    }
    else if(n==16)
    {
        if(nn(0,8))
            printf("8");
        else if(nn(8,16))
            printf("8");
        else
        {
            if(nn(0,4))
                printf("4");
            else if(nn(4,8))
                printf("4");
            else if(nn(8,12))
                printf("4");
            else if(nn(12,16))
                printf("4");
            else
            {
                if(nn(0,2))
                    printf("2");
                else if(nn(2,4))
                    printf("2");
                else if(nn(4,6))
                    printf("2");
                else if(nn(6,8))
                    printf("2");
                else if(nn(8,10))
                    printf("2");
                else if(nn(10,12))
                    printf("2");
                else if(nn(12,14))
                    printf("2");
                else if(nn(14,16))
                    printf("2");
                else
                    printf("1");

            }
        }
    }
    return 0;
}


#include<stdio.h>
int a[100];
int nn(int p,int q)
{
    int i;
    for(i=p+1; i<q; i++)
        if(a[i]<=a[p])
            return 0;
    return 1;
}
int main()
{
    int n,max=0,i,m;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(nn(0,n))
    {
        printf("%d",n);
        return 0;
    }
    else if(n==2)
    {
        printf("%d",n/2);
        return 0;
    }
    else if(n==4)
    {
        if(nn(0,2))
            printf("%d",n/2);
        else if(nn(2,4))
            printf("%d",n/2);
        else
            printf("1");

    }
    else if(n==8)
    {
        if(nn(0,4))
            printf("%d",n/2);
        else if(nn(4,8))
            printf("%d",n/2);
        else
        {
            if(nn(0,2))
                printf("2");
            else if(nn(2,4))
                printf("2");
            else if(nn(4,6))
                printf("2");
            else if(nn(6,8))
                printf("2");
            else
                printf("1");
        }
    }
    else if(n==16)
    {
        if(nn(0,8))
            printf("%d",n/2);
        else if(nn(8,16))
            printf("%d",n/2);
        else
        {
            if(nn(0,4))
                printf("4");
            else if(nn(4,8))
                printf("4");
            else if(nn(8,12))
                printf("4");
            else if(nn(12,16))
                printf("4");
            else
            {
                if(nn(0,2))
                    printf("2");
                else if(nn(2,4))
                    printf("2");
                else if(nn(4,6))
                    printf("2");
                else if(nn(6,8))
                    printf("2");
                else if(nn(8,10))
                    printf("2");
                else if(nn(10,12))
                    printf("2");
                else if(nn(12,14))
                    printf("2");
                else if(nn(14,16))
                    printf("2");
                else
                    printf("1");

            }
        }
    }
    return 0;
}


#include<stdio.h>
int a[100];
int nn(int p,int q)
{
    int i;
    for(i=p+1; i<q; i++)
        if(a[i]<=a[i-1])
            return 0;
    return 1;
}
int main()
{
    int n,max=0,i,m;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(nn(0,n))
    {
        printf("%d",n);
        return 0;
    }
    else if(n==2)
    {
        printf("%d",n/2);
        return 0;
    }
    else if(n==4)
    {
        if(nn(0,2))
            printf("%d",n/2);
        else if(nn(2,4))
            printf("%d",n/2);
        else
            printf("1");

    }
    else if(n==8)
    {
        if(nn(0,4))
            printf("%d",n/2);
        else if(nn(4,8))
            printf("%d",n/2);
        else
        {
            if(nn(0,2))
                printf("2");
            else if(nn(2,4))
                printf("2");
            else if(nn(4,6))
                printf("2");
            else if(nn(6,8))
                printf("2");
            else
                printf("1");
        }
    }
    else if(n==16)
    {
        if(nn(0,8))
            printf("8");
        else if(nn(8,16))
            printf("8");
        else
        {
            if(nn(0,4))
                printf("4");
            else if(nn(4,8))
                printf("4");
            else if(nn(8,12))
                printf("4");
            else if(nn(12,16))
                printf("4");
            else
            {
                if(nn(0,2))
                    printf("2");
                else if(nn(2,4))
                    printf("2");
                else if(nn(4,6))
                    printf("2");
                else if(nn(6,8))
                    printf("2");
                else if(nn(8,10))
                    printf("2");
                else if(nn(10,12))
                    printf("2");
                else if(nn(12,14))
                    printf("2");
                else if(nn(14,16))
                    printf("2");
                else
                    printf("1");

            }
        }
    }
    return 0;
}


#include <stdio.h>
int check1(int a[],int n);
int check2(int a[],int n,int h,int m);
int main()
{
    int n,i,r,y,x=2,z=0,h,m;
    scanf("%d" ,&n);
    m=n;
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d" ,&a[i]);
    }
    r=check1(a,n);
    if(r==1){printf("%d" ,n);}
    else if(r==-1){printf("1");}
    else
    {
        while(x<=16)
        {
            y=n/x;
            if(x>=2){r=check1(a,y);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,y,h,m);
            if(r==1){printf("%d" ,y);return 0;}
            }
            if(x>=4)
            {
                h=4;
            r=check2(a,(y+x),h,m);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,(y+2*x),h,m);
            if(r==1){printf("%d" ,y);return 0;
            }
            }
            z++;
            x=2*x;
        }
        if(z==2){printf("2");}
}
}
int check1(int a[],int n)
{
    int i,y=0,x=0;
    for(i=0;i<n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}
int check2(int a[],int n,int h,int m)
{
    int i,y=0,x=0;
    for(i=n;i<(m-h);i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==(m-h)-n)
        return 1;
    else if(x==(m-h)-n)
        return -1;
    else
        return 0;
}


#include <stdio.h>
int check1(int a[],int n);
int check2(int a[],int n,int h,int m);
int main()
{
    int n,i,r,y,x=2,z=0,h,m;
    scanf("%d" ,&n);
    m=n;
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d" ,&a[i]);
    }
    r=check1(a,n);
    if(r==1){printf("%d" ,n);}
    else if(r==-1){printf("1");}
    else
    {
        while(x<m)
        {
            y=n/x;
            if(x>=2){r=check1(a,y);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,y,h,m);
            if(r==1){printf("%d" ,y);return 0;}
            }
            if(x>=4)
            {
                h=4;
            r=check2(a,(y+x),h,m);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,(y+2*x),h,m);
            if(r==1){printf("%d" ,y);return 0;
            }
            }
            z++;
            x=2*x;
        }
        printf("2");
}
}
int check1(int a[],int n)
{
    int i,y=0,x=0;
    for(i=0;i<n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}
int check2(int a[],int n,int h,int m)
{
    int i,y=0,x=0;
    for(i=n;i<(m-h);i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==(m-h)-n)
        return 1;
    else if(x==(m-h)-n)
        return -1;
    else
        return 0;
}


int check1(int a[],int n);
int check2(int a[],int n);
int main()
{
    int n,i,r;
    scanf("%d" ,&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d" ,&a[i]);
    }
    r=check1(a,n);
    if(r==1){printf("%d" ,n);}
    else if(r==-1){printf("1");}
    else
    {
       int x=n/2;
        r=check1(a,x);
        if(r==1){printf("%d" ,x);}
        else
        {
        r=check2(a,x);
        if(r==1){printf("%d" ,x);}
        else
        {
        int y=x/2;
        r=check1(a,y);
        if(r==1){printf("%d" ,y);return 0;}
        r=check2(a,y);
        if(r==1){printf("%d" ,y);}
        else
        {
         int y=x/2+2*(y/2);
        r=check1(a,y);
        if(r==1){printf("%d" ,y);return 0;}
        r=check2(a,y);
        if(r==1){printf("%d" ,y);}
        else
        {
        printf("2");
        }
        }

    }
}
    }
}
int check1(int a[],int n)
{
    int i,y=0,x=0;
    for(i=0;i<n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}
int check2(int a[],int n)
{
    int i,y=0,x=0;
    for(i=n;i<2*n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}


#include <stdio.h>
int check1(int a[],int n);
int check2(int a[],int n,int h);
int main()
{
    int n,i,r,y,x=2,z=0,h;
    scanf("%d" ,&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d" ,&a[i]);
    }
    r=check1(a,n);
    if(r==1){printf("%d" ,n);}
    else if(r==-1){printf("1");}
    else
    {
        while(x<=16)
        {
            y=n/x;
            if(x>=2){r=check1(a,y);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,y,h);
            if(r==1){printf("%d" ,y);return 0;}
            }
            if(x>=4)
            {
                h=4;
            r=check2(a,(y+x),h);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,(y+2*x),h);
            if(r==1){printf("%d" ,y);return 0;
            }
            }
            z++;
            x=2*x;
        }
}
}
int check1(int a[],int n)
{
    int i,y=0,x=0;
    for(i=0;i<n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}
int check2(int a[],int n,int h)
{
    int i,y=0,x=0;
    for(i=n;i<(16-h);i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==(16-h)-n)
        return 1;
    else if(x==(16-h)-n)
        return -1;
    else
        return 0;
}


#include <stdio.h>
int check1(int a[],int n);
int check2(int a[],int n,int h,int m);
int main()
{
    int n,i,r,y,x=2,z=0,h,m;
    scanf("%d" ,&n);
    m=n;
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d" ,&a[i]);
    }
    r=check1(a,n);
    if(r==1){printf("%d" ,n);}
    else if(r==-1){printf("1");}
    else
    {
        while(x<=16)
        {
            y=n/x;
            if(x>=2){r=check1(a,y);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,y,h,m);
            if(r==1){printf("%d" ,y);return 0;}
            }
            if(x>=4)
            {
                h=4;
            r=check2(a,(y+x),h,m);
            if(r==1){printf("%d" ,y);return 0;}
            h=0;
            r=check2(a,(y+2*x),h,m);
            if(r==1){printf("%d" ,y);return 0;
            }
            }
            z++;
            x=2*x;
        }
}
}
int check1(int a[],int n)
{
    int i,y=0,x=0;
    for(i=0;i<n-1;i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==n-1)
        return 1;
    else if(x==n-1)
        return -1;
    else
        return 0;
}
int check2(int a[],int n,int h,int m)
{
    int i,y=0,x=0;
    for(i=n;i<(m-h);i++)
    {if(a[i]>a[i+1])
            x++;
    if(a[i]<=a[i+1])
            y++;}
    if(y==(m-h)-n)
        return 1;
    else if(x==(m-h)-n)
        return -1;
    else
        return 0;
}


#include<stdio.h>

bool valid(int* nums, int numsSize) {
    if (numsSize == 1) {
        return true;
    }
    for (int i=1; i<numsSize; i++) {
        if (nums[i] < nums[i-1]) {
            return false;
        }
    }
    return true;
}

int search(int* nums, int numsSize) {

    if (valid(nums, numsSize)) {
        return numsSize;
    }
    int ret1 = search(nums, numsSize / 2);
    int ret2 = search(nums + (numsSize / 2), numsSize / 2);
    if (ret1 > ret2) {
        return ret1;
    } else {
        return ret2;
    }
}

int n,m[17];

int main () {
    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        scanf("%d", &m[i]);
    }
    int res=search(n, m);
    printf("%d\n", res);
}


#include<stdio.h>
#include<stdint.h>

int valid(int* nums, int numsSize) {
	int i;
    if (numsSize == 1) {
        return 1;
    }
    for (i=1; i<numsSize; i++) {
        if (nums[i] < nums[i-1]) {
            return 0;
        }
    }
    return 1;
}

int search(int* nums, int numsSize) {

    if (valid(nums, numsSize)) {
        return numsSize;
    }
    int ret1 = search(nums, numsSize / 2);
    int ret2 = search(nums + (numsSize / 2), numsSize / 2);
    if (ret1 > ret2) {
        return ret1;
    } else {
        return ret2;
    }
}

int n,m[17];

int main () {
	int i, res;
    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%d", &m[i]);
    }
    res=search(m, n);
    printf("%d\n", res);
}


#include <stdio.h>
#include <stdlib.h>

int max_len;

int sorted(int* arr, int start, int len) {
    for (int i = start; i<start+len-1; i++) {
        if (arr[i]>arr[i+1])
            return 0;
    }
    return 1;
}

int max(int a, int b) {
    return (a>b) ? a : b;
}

int longestSorted(int* arr, int start, int len) {
    if ((sorted(arr, start, len)))
        return len;
    else {
        return max(longestSorted(arr, start, len/2), longestSorted(arr, start+len/2, len/2));
    }
}

int main(int argc, char **argv)
{
	int n,i;
    int *arr;

	scanf("%d", &n);
	arr = malloc(sizeof(int)*n);
    for(int i=0; i < n; i++)
        scanf("%d", &arr[i]);
    printf("%d", longestSorted(arr, 0, n));

	return 0;
}


#include<stdio.h>
int sort(int a[],int n);
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    printf("%d",sort(a,n));
}

int sort(int a[],int n){
    for(int i=0;i<n-1;i++){
        if(a[i]<=a[i+1]){
            continue;
        }
        else{
            return sort(a,n/2);
        }
    }
    return n;
}


#include<stdio.h>
int sort(int a[],int s,int e){
    int count=1;
    for(int i=s;i<e-1;i++){
        if(a[i]<=a[i+1]){
            count++;
        }
        else{
            if(sort(a,s,(e+s)/2)>sort(a,(s+e)/2,e)){
                count=sort(a,s,(e+s)/2);
            }else{
                count=sort(a,(e+s)/2,e);
            }
            break;
        }
    }
    return count;
}
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    printf("%d",sort(a,0,n));
}


#include <stdio.h>
#include <stdlib.h>

int main( ) {

   char str1[100];
   char str2[100];
   char str3[100];

   fgets(str1, sizeof(str1), stdin);
   fgets(str2, sizeof(str2), stdin);

   int i=atoi(str1);

   int n[i];

   int k=0;
   int m=0;
   int p=0;

   while (str2[k]!='\0'){
       if (str2[k]!=' '){
           str3[m]=str2[k];
           m++;
           k++;
       }else {
           n[p]=atoi(str3);
           memset(str3,0,sizeof(str3));
           m=0;
           k++;
           p++;
       }
   }
   n[p]=atoi(str3);

   //printf("%d", p);

   //printf("%d %d %d %d %d %d %d %d",n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]);

   int issorted=0;
   int f;

   while (issorted<1){
       f=0;
       for (int q=1;q<i;q++){
           if (n[q]<n[q-1]){
               f=1;
           }
       }

       if (f==1){
           i=i/2;

        }else {
            issorted=1;
        }
   }

    printf("%d",i);
   return 0;
}


#include <stdio.h>

int main (){
    int num,i,f=1,tmp=0,tmp2=2,j,ct,f1;
    scanf("%d\n",&num);
    int x[num];
    for (i=0;i<num;i++){
        scanf("%d ", &x[i]);
    }

    while (f>0 && tmp2<=num){
        f1=0;
        for (i=0;i<(num/(float)tmp2);i++){
            ct=0;
            for (j=tmp;j<tmp+tmp2-1;j++){
                if (x[j]<=x[j+1]){
                    ct=ct+1;
                }
            }
            if (ct==tmp2-1){
                f1=1;
            }
            tmp=tmp+tmp2;
        }
        if (f1==1){
            tmp2=tmp2*2;
            tmp=0;
        }else{
            f=0;
        }

    }

    printf("%d",tmp2/2);

    return 0;

}


#include <stdio.h>

int main (){
    int num,i,f=1,tmp=0,tmp2=2,j,ct,f1;
    scanf("%d\n",&num);
    int x[num];
    for (i=0;i<num;i++){
        scanf("%d ", &x[i]);
    }

    while (f>0 && tmp2<=num){
        f1=0;
        for (i=0;i<(num/(float)tmp2);i++){
            ct=0;
            for (j=tmp;j<tmp+tmp2-1;j++){
                if (x[j]<x[j+1]){
                    ct=ct+1;
                }
            }
            if (ct==tmp2-1){
                f1=1;
            }
            tmp=tmp+tmp2;
        }
        if (f1==1){
            tmp2=tmp2*2;
            tmp=0;
        }else{
            f=0;
        }

    }

    if (f==0){
        printf("%d",tmp2/2);
    }else{
        printf("%d",tmp2/2);
    }

    return 0;

}


#include<stdio.h>
#include<stdbool.h>

bool check_sorted (int* a,int start, int end) {
	int i;
	for (i=start;i<end-1;i++) {
		if(a[i]>a[i+1])
			return false;
	}
	return true;
}

int func(int* a, int i, int n) {
	//printf("%d %d\n",i,n);
	if (check_sorted(a,i,n)==true) {
		return (n-i);
	}
	else {
		int x=func(a,i,(n+i)/2);
		//printf("%d", x);
		int y=func(a,(n+i)/2,n);
		//printf(" %d\n",y);
		if(x>=y)
			return x;
		else
			return y;
	}
}

int main() {
	int n,i;
	scanf("%d",&n);
	int a[n];
	int *p = a;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	//printf("%d\n\n",check_sorted(p,0,n));
	int check = 0;
	for(i=0;i<n-1;i++)
	{
		if(a[i]>a[i+1]) {
			printf("%d",func(p,0,n));
			return 0;
		}
	}
	printf("%d",n);
	return 0;
}


#define SIZE 16

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

bool check_if_subarray_sorted(array, start, end)
    unsigned array[];
    size_t start, end;
{
    while (++start < end)
        if (array[start - 1] > array[start])
            return false;
    return true;
}

size_t read_array(array)
    unsigned array[];
{
    unsigned array_size;
    scanf("%u", &array_size);
    for (size_t i = 0; i < array_size; ++i)
        scanf("%u", &array[i]);
    return array_size;
}

int main(void) {
    static unsigned array[SIZE];
    size_t array_size;
    array_size = read_array(array);
    size_t step = array_size;
    while (true) {
        for (size_t start = 0; start + step <= array_size; start += step)
            if (check_if_subarray_sorted(array, start, start + step)) {
                printf("%"
#ifdef ONLINE_JUDGE
                        "%I64u"
#else
                        "llu"
#endif
                        "\n", (unsigned long long)step);
                return EXIT_SUCCESS;
            }
        step /= 2;
    }
}


#define SIZE 16

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

bool check_if_subarray_sorted(array, start, end) :
    unsigned array[];
    size_t start, end;
{
    while (++start < end)
        if (array[start - 1] > array[start])
            return false;
    return true;
}

size_t read_array(array)
    unsigned array[];
{
    size_t array_size;
    scanf("%zu", &array_size);
    for (size_t i = 0; i < array_size; ++i)
        scanf("%u", &array[i]);
    return array_size;
}

int main(void) {
    static unsigned array[SIZE];
    size_t array_size;
    array_size = read_array(array);
    size_t step = array_size;
    while (true) {
        for (size_t start = 0; start + step <= end; start += array_size)
            if (check_if_subarray_sorted(array, start, start + step)) {
                printf("%zu\n", step);
                return EXIT_SUCCESS;
            }
        step /= 2;
    }
}


#define SIZE 16

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

bool check_if_subarray_sorted(array, start, end)
    unsigned array[];
    size_t start, end;
{
    while (++start < end)
        if (array[start - 1] > array[start])
            return false;
    return true;
}

size_t read_array(array)
    unsigned array[];
{
    unsigned array_size;
    scanf("%u", &array_size);
    for (size_t i = 0; i < array_size; ++i)
        scanf("%u", &array[i]);
    return array_size;
}

int main(void) {
    static unsigned array[SIZE];
    size_t array_size;
    array_size = read_array(array);
    size_t step = array_size;
    while (true) {
        for (size_t start = 0; start + step <= array_size; start += step)
            if (check_if_subarray_sorted(array, start, start + step)) {
                printf("%"
#ifdef ONLINE_JUDGE
                        "I64u"
#else
                        "llu"
#endif
                        "\n", (unsigned long long)step);
                return EXIT_SUCCESS;
            }
        step /= 2;
    }
}


#define SIZE 16

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

bool check_if_subarray_sorted(array, start, end)
    unsigned array[];
    size_t start, end;
{
    while (++start < end)
        if (array[start - 1] > array[start])
            return false;
    return true;
}

size_t read_array(array)
    unsigned array[];
{
    size_t array_size;
    scanf("%zu", &array_size);
    for (size_t i = 0; i < array_size; ++i)
        scanf("%u", &array[i]);
    return array_size;
}

int main(void) {
    static unsigned array[SIZE];
    size_t array_size;
    array_size = read_array(array);
    size_t step = array_size;
    while (true) {
        for (size_t start = 0; start + step <= array_size; start += step)
            if (check_if_subarray_sorted(array, start, start + step)) {
                printf("%zu\n", step);
                return EXIT_SUCCESS;
            }
        step /= 2;
    }
}


#include <stdio.h>
unsigned short is_sorted(unsigned short*, unsigned short*);
int main()
{
    unsigned short n, a[16], i, j;
    scanf("%hu", &n);
    for(i = 0; i < n; i++){ scanf("%hu", a + i); }
    for(i = n; i > 0; i >>= 1){
        for(j = 0; j < n; j += i){
            if(is_sorted(a + j, a + i + j)){ printf("%hu", i); return 0;}
        }
    }

    return 0;
}
unsigned short is_sorted(unsigned short* a, unsigned short* b){
    while(a != b - 1){
        if(a[0]> a[1]){ return 0;}
        a++;
    }
    return 1;
}


#include <stdio.h>
#include <stdlib.h>
int count = 0;
int array[1000] = {0};
short int sorted = 1;
int main(void)
{
    scanf("%d\n", &count);
    for(int i = 0; i < count; i++)
        scanf("%d", &array[i]);
    for(int i = 0; i < count - 1; i++)
    {
        if(array[i] > array[i + 1])
        {
            sorted = 0;
            break;
        }
    }
    if(sorted)
    {
        printf("%d", count);
        exit(0);
    }

    while(count > 1){
        for(int i = 0; i < count/2 - 1; i++)
        {
            if(array[i] > array[i + 1])
            {
                sorted = 0;
                break;
            }
        }
        sorted = 1;
        for(int i = count/2; i < count - 1; i++)
        {
            if(array[i] > array[i + 1])
            {
                sorted = 0;
                break;
            }
        }
        count = count/2;
        if(sorted)
        {
            printf("%d", count);
            exit(0);
        }
        else
         sorted = 1;
    }
    printf("%d", count);
}


#include <stdio.h>
#include <stdlib.h>
int max_size = 1;
int size = 0;
int array[1000] = {0};
short int sorted = 1;

int Tanos_sort(int * a, int size, int position)
{
    if(size == 1)
        return 1;
    if(is_sorted(a, position, size) && (size >= max_size) )
        max_size  = size;
    else
    {
        Tanos_sort(a, size/2, 0);
        Tanos_sort(a, size/2, size/2);
    }
}

int is_sorted(int * array, int pstn, int size)
{
int i = 0;
    for( i = pstn; i < size + pstn - 1; i++)
        if(array[i] > array[i + 1])
            return 0;
    return 1;
}

int main(void)
{
	int i = 0;
    scanf("%d\n", &size);
    for(i = 0; i < size; i++)
        scanf("%d", &array[i]);
    Tanos_sort(array, size, 0);
    printf("%d", max_size);

}


#include <stdio.h>
#include <stdlib.h>
int max_size = 1;
int size = 0;
int array[1000] = {0};
short int sorted = 1;

int Tanos_sort(int * a, int size, int position)
{
    if(size == 1)
        return 1;
    if(is_sorted(a, position, size) && (size >= max_size) )
        max_size  = size;
    else
    {
        Tanos_sort(a, size/2, 0);
        Tanos_sort(a, size/2, size/2);
    }
}

int is_sorted(int * array, int pstn, int size)
{
    for(int i = pstn; i < size + pstn - 1; i++)
        if(array[i] > array[i + 1])
            return 0;
    return 1;
}

int main(void)
{
    scanf("%d\n", &size);
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    Tanos_sort(array, size, 0);
    printf("%d", max_size);

}


#include <stdio.h>
#include <stdlib.h>
int max_size = 1;
int size = 0;
int array[1000] = {0};
short int sorted = 1;

int Tanos_sort(int * a, int size, int position)
{
    if(size == 1)
        return 1;
    if(is_sorted(a, position, size) && (size >= max_size) )
        max_size  = size;
    else
    {
        Tanos_sort(a, size/2, 0);
        Tanos_sort(a, size/2, size/4);
    }
}

int is_sorted(int * array, int pstn, int size)
{
int i = 0;
    for( i = pstn; i < size - 1; i++)
        if(array[i] > array[i + 1])
            return 0;
    return 1;
}

int main(void)
{
	int i = 0;
    scanf("%d\n", &size);
    for(i = 0; i < size; i++)
        scanf("%d", &array[i]);
    Tanos_sort(array, size, 0);
    printf("%d", max_size);

}


#include <stdio.h>
#include <stdlib.h>
int max_size = 1;
int size = 0;
int array[1000] = {0};
short int sorted = 1;

int Tanos_sort(int * a, int size)
{
    if(size == 1)
        return 1;
    if(is_sorted(a, size) && (size >= max_size) )
        max_size  = size;
    else
    {
        Tanos_sort(a, size/2);
        Tanos_sort(&a[size/2], size/2);
    }
}

int is_sorted(int * array, int size)
{
    for(int i = 0; i < size - 1; i++)
        if(array[i] > array[i + 1])
            return 0;
    return 1;
}

int main(void)
{
    scanf("%d\n", &size);
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    Tanos_sort(array, size);
    printf("%d", max_size);

}


#include <stdio.h>
#include <stdlib.h>
int max_size = 1;
int size = 0;
int array[1000] = {0};
short int sorted = 1;

int Tanos_sort(int * a, int size, int position)
{
    if(size == 1)
        return 1;
    if(is_sorted(a, position, size) && (size >= max_size) )
        max_size  = size;
    else
    {
        Tanos_sort(a, size/2, 0);
        Tanos_sort(a, size/2, size/2);
    }
}

int is_sorted(int * array, int pstn, int size)
{
int i = 0;
    for( i = pstn; i < size * 2 - 1; i++)
        if(array[i] > array[i + 1])
            return 0;
    return 1;
}

int main(void)
{
	int i = 0;
    scanf("%d\n", &size);
    for(i = 0; i < size; i++)
        scanf("%d", &array[i]);
    Tanos_sort(array, size, 0);
    printf("%d", max_size);

}


#include<stdio.h>
#define SIZE 16

  int arr[SIZE];
  int max=1;
 int main()
 {
    int i,n;
     scanf("%d",&n);

     for(i=0;i<n;i++)
     {
         scanf("%d",&arr[i]);
     }
     snap(0,n-1);
     printf("%d\n",max);
     return 0;

 }

 int check(start,end)
 {
     for(int i=start;i<=end-1;i++)
	{
		if(arr[i]>arr[i+1])
			return 0;
	}

	return 1;
 }

 int snap(int start, int end)
 {
     if(start!=end)
     {
         if (check(start,end)==1)
         {
             int result=end-start+1;
             if(result>max)
             {
                 max=result;
             }
         }
         else
         {
             int half=(start+end)/2;
             snap(start,half);
                snap(half+1,end);

         }
     }

 }


#include<stdio.h>
int sortlen(int a[],int x,int y)
{
    int c=0,i,maxlen=0;
    for(i=x;i<y-1;i++)
    {
        if(a[i]<=a[i+1])
        {
            c++;
            if(c>maxlen)
                maxlen=c;
        }
        else
            c=0;
    }
    return maxlen;
}
int thanos(int a[],int x,int y)
{
    if(sortlen(a,x,y)==y-x-1)
        return y-x;
    int p=thanos(a,x,(x+y)/2);
    int q=thanos(a,(x+y)/2,y);
    return (p>q)?p:q;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int j=thanos(a,0,n);
    printf("%d",j);
    return 0;
}


#include<stdio.h>
int sortlen(int a[],int x,int y)
{
    int c=0,i,maxlen=0;
    for(i=x;i<y-1;i++)
    {
        if(a[i]<=a[i+1])
        {
            c++;
            if(c>maxlen)
                maxlen=c;
        }
        else
            c=0;
    }
    return maxlen;
}
int thanos(int a[],int x,int y)
{
    if(sortlen(a,x,y)==y-x-1)
        return y-x;
    int p=thanos(a,x,(x+y)/2);
    int q=thanos(a,(x+y)/2,y);
    return (p>q)?p:q;
}
void main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int j=thanos(a,0,n);
    printf("%d",j);
}


#include<stdio.h>
_Bool sorted(int a[],int x,int y)
{
    int i;
    for(i=x;i<y-1;i++)
    {
        if(a[i]>a[i+1])
            return 0;
    }
    return 1;
}
int thanos(int a[],int x,int y)
{
    if(sorted(a,x,y))
        return y-x;
    int p=thanos(a,x,(x+y)/2);
    int q=thanos(a,(x+y)/2,y);
    return (p>q)?p:q;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int j=thanos(a,0,n);
    printf("%d",j);
    return 0;
}


#include <stdio.h>
#define max(a,b) a>b?a:b
int sort(int a[],int s,int n)
{
    int i,p=1;
    for(i=s;i<s+n-1;i++)
    {
        if(a[i]>a[i+1]){p=0;break;}
    }
    if(p==1)return n;
    return max(sort(a,s,n/2),sort(a,s+(n/2),n/2));

}
int main() {
	//code
	int n,a[16],i;
	scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",a+i);
    printf("%d",sort(a,0,n));
	return 0;
}


#include<stdio.h>
#include<conio.h>
int main(){
    int half,length,num[1000],i,j,k,m,n;
    scanf("%d",&length);
    for (i=0;i<length ;i++ )
    {
        scanf("%d",&num[i]);
    }
    //for (i=0;i<length ;i++ )
   // {
    //    printf("%d ",num[i]);
    //}
    while(1){
    m=0;
    n=0;
    half=(length/2)-1;
     for (i=0;i<length-1 ;i++ )
     {
         if(num[i]>num[i+1]){
             if(i<=half){
                m++;
             }
             if(i>half){
                n++;
             }
         }
     }
     if(m==0&&n==0){
        break;
     }
    //printf("\n%d %d\n",m,n);
    if(m>=n){
       // printf("Mahin\n");
        i=0;
        for (k=half+1;k<length ;k++ )
        {

            num[i]=num[k];
            i++;
           // printf("\n%d %d\n",k,i);
        }
         length=half+1;
    }
    if(m<n){
        length=half+1;
       // printf("Mahin2\n");
    }
   // for (i=0;i<length ;i++ )
   // {
    //    printf("%d ",num[i]);
   // }
    }
    printf("%d",length);
   return 0;
}


#include<stdio.h>
#include<conio.h>
int main(){
    int half,length,num[1000],i,j,k,m,n;
    scanf("%d",&length);
    for (i=0;i<length ;i++ )
    {
        scanf("%d",&num[i]);
    }
    /*for (i=0;i<length ;i++ )
    {
        printf("%d ",num[i]);
    }*/
    while(1){
    m=0;
    n=0;
    half=(length/2)-1;
     for (i=0;i<length-1 ;i++ )
     {
         if(num[i]>num[i+1]){
             if(i<=half){
                m++;
             }
             if(i>half){
                n++;
             }
         }
     }
     if(m==0&&n==0){
        break;
     }
    if(m>=n){
            length=half+1;
        for (k=half+1;k<length ;k++ )
        {
            i=0;
            num[i]=num[k];
            i++;
        }
    }
    if(m<n){
        length=half+1;
    }
    }
    printf("%d",length);
   return 0;
}


//
// Created by Terry Cruz Melo on 3/4/20.
//

//
// Created by Terry Cruz Melo on 3/3/20.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main () {
	int tests;
	scanf("%i", &tests);
	int numbers[tests];

	for (int i = 0; i < tests; i++) {

		scanf("%i", &numbers[i]);

	}
	int counterA = 1;
	for (int i = 0; i < tests-1; i++) {

		if (numbers[i]<=numbers[i+1])
		{
			counterA+=1;
		}
		else
		{
			break;
		}
	}
	int counterB=1;
	for (int i = tests/2; i < tests-1; i++) {

		if (numbers[i]<=numbers[i+1])
		{
			counterB+=1;

		}
		else
		{
			break;
		}
	}

	int counterMAX =  (counterA>=counterB) ? counterA:counterB;
	int i=0;
	while (1)
	{
		if (counterMAX >= pow(2,i) && counterMAX < pow(2,i+1))
			break;
		else{
			i+=1;
		}
	}

	printf("%01.f",pow(2,i));
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main () {
	int tests;
	scanf("%i", &tests);
	int numbers[tests];

	for (int i = 0; i < tests; i++) {

		scanf("%i", &numbers[i]);

	}
	int counter = 1;
	for (int i = 0; i < tests-1; i++) {

		if (numbers[i]<=numbers[i+1])
		{
			counter+=1;
		}
		else
		{
			break;
		}
	}
	int i=0;
	while (1)
	{
		if (counter >= pow(2,i) && counter < pow(2,i+1))
			break;
		else{
			i+=1;
		}
	}

	printf("%01.f",pow(2,i));
}


#include<stdio.h>

#define nax 100

int rec(int arr[],int ini, int final){
	//tamano maximo del arreglo ordenado
	int esCreciente = 1;
	for(int i = ini; i < final; i++){
		if(esCreciente && arr[i]<=arr[i+1]) continue;
		else esCreciente = 0;
	}
	if(esCreciente) return final - ini + 1;
	// Si no lo es:
	int mid = (ini + final)/2;
	int aux1 = rec(arr,ini, mid);
	int aux2 = rec(arr,mid+1, final);
	return (aux1>aux2)? aux1:aux2;
}

int main(){
	int n, arr[nax];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&arr[i]);
	}
	printf("%d",rec(arr,0,n-1));

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int ordenado(int *v, int ini, int tam)
{
   int i, ant;

   for (i=1; i<tam; i++)
      if (v[ (ini+i)-1 ] > v[ (ini+i) ])
         return 0;

   return 1;
}

int nenhum_ordenado (int *v, int n, int *tam)
{
   int ini = 0;

   if (*tam == 1)
      return 0;

   /*percorre subvetores*/
   while (ini + *tam <= n)
   {
      if (ordenado(v, ini, *tam))
         return 0;
      ini += *tam;
   }
   *tam /= 2;
   return 1;
}

int main(){
   int n, i, max_tam;
   int *v;

   scanf("%d", &n);
   v = (int *) malloc(n * sizeof(int));

   for (i=0; i<n; i++)
      scanf("%d", v+i);

   max_tam = n;
   while (nenhum_ordenado(v, n, &max_tam)){}

   printf("%d\n", max_tam);
   return 0;
}


#include <stdio.h>
#include <stdlib.h>

int is_sorted(int *arr, int begin, int end)
{
	for (int i = begin; i < end - 1; i++)
	{
		if (arr[i] > arr[i + 1])
			return (0);
	}
	return (1);
}

int tanos_sort(int *arr, int begin, int end)
{
	int len = end - begin;
	int lres, rres;

	if (is_sorted(arr, begin, end))
		return (len);
	if (len == 2)
		return (1);
	rres = tanos_sort(arr, begin + len / 2, end);
	lres = tanos_sort(arr, begin, end - len / 2 );
	return (rres > lres ? rres : lres);
}

int main() {
	int	*arr;
	int n;

	scanf("%d", &n);
	arr = malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	printf("%d\n", tanos_sort(arr, 0, n));
	return 0;
}


#include<stdio.h>

int max(int a,int b)
{
    if(a>b)
        return a;
    return b;
}
int doit(int a[],int low,int high)
{
   if(low==high)    //1 element
        return 1;
   else
   {
       int flag=1;
       for(int i=low;i<high;i++)
        if(a[i]>a[i+1])
            flag=0;
       if(flag==1)
        return high-low+1;
        int mid=(low+high)/2;
       int left=doit(a,low,mid);
       int right=doit(a,mid+1,high);
       return max(left,right);
   }
}
int main()
{
    int n;
    int a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int count=doit(a,0,n-1);
    printf("\ncount=%d",count);
}


#include<stdio.h>
int a[100];
int sort(int ft,int et,int n)
{
int i,s1=0,s2=0,s3=0,k=0;
int score1=0,score2=0;
printf("ft is: %d   et is: %d\n",ft,et);
for(i=ft;i<et-1;i++)
 {

  if(a[i]<=a[i+1])
	{
		s3++;
	}
	k++;
  }

  printf("k is: %d  s3 is: %d\n",k,s3);
 if(s3==k)
	{
		return s3+1;

	}
 else
  {

 	for(i=ft;i<et/2-1;i++)
	 {
		if(a[i]<=a[i+1])
		{
			score1++;
			s1++;
		}
		else if(s1<=score1)
	      {
		    s1=score1;
		   score1=0;
	     }
	 }
	for(i=et/2;i<et-1;i++)
	 {
		if(a[i]<=a[i+1])
		{
			score2++;
			s2++;
		}
		else if(s2<=score2)
	    {
		   s2=score2;
   		   score2=0;
		}
	 }
   printf("s1 is: %d\n",s1);
   printf("s2 is %d\n",s2);
   if(s1>s2)
   {
   	 sort(0,n/2,n/2);
   }
   else if(s1<s2)
   {
   	sort(n/2,n,n/2);
   }
   else if(s1==s2)
   {
   	 sort(0,n/2,n/2);
   }
 }
}
int main()
{
 int n,i;
 scanf("%d",&n);
 printf("\n");
 for(i=0;i<n;i++)
 {
 	scanf("%d",&a[i]);
 }
 printf("\n");
 int res=sort(0,n,n);
 printf("%d",res);

 return 0;

}


#include<stdio.h>

int max(int a,int b)
{
    if(a>b)
        return a;
    return b;
}
int doit(int a[],int low,int high)
{
   if(low==high)    //1 element
        return 1;
   else
   {
       int flag=1;
       for(int i=low;i<high;i++)
        if(a[i]>a[i+1])
            flag=0;
       if(flag==1)
        return high-low+1;
        int mid=(low+high)/2;
       int left=doit(a,low,mid);
       int right=doit(a,mid+1,high);
       return max(left,right);
   }
}
int main()
{
    int n;
    int a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int count=doit(a,0,n-1);
    printf("%d\n",count);
}


/*  Problem Statement: https://codeforces.com/problemset/problem/1145/A
 *  Author: striker
*/

#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
#include<stdbool.h>

#define CONSTRAINTS_OUT_OF_BOUND_ERROR(variable,constraints) fprintf(stderr,"Line number: %u: Constraint not satified. <%s> should be under the given constraints i.e %s.\n", __LINE__, #variable, #constraints)
#define MEMORY_ALLOCATION_FAILED_ERROR(variable,bytes) fprintf(stderr,"Line number: %u: Not able to allocate the memory to <%lu> bytes of memory to <%s> variable\n", __LINE__, (bytes), #variable)

static bool check_sorted(const uint32_t *const, const uint32_t, const uint32_t);
static int32_t thanos_sort(const uint32_t *const, const uint32_t, const uint32_t); // Recursive Function.
static int32_t max(const int32_t, const int32_t);

int main(void) {
    uint32_t n;
    scanf("%u", &n);
    if(n & (n - 1)) {
        CONSTRAINTS_OUT_OF_BOUND_ERROR(n, "2^n");
        exit(0);
    }
    uint32_t *const data = calloc(n, sizeof(*data));
    if(data) {
        for(uint32_t i = 0; i < n; ++i) {
            scanf("%u", (data + i));
            if(data[i] < 1 || data[i] > 101) {
                CONSTRAINTS_OUT_OF_BOUND_ERROR(data[i], "1 <= data[i] <= 100");
                exit(0);
            }
        }
        printf("%d\n", thanos_sort(data, 0, (n - 1)));
        free(data);
    } else {
        MEMORY_ALLOCATION_FAILED_ERROR(*data, n * sizeof(*data));
        exit(0);
    }
    return EXIT_SUCCESS;
}

static bool check_sorted(const uint32_t *const data, const uint32_t start, const uint32_t end) {
    bool is_sorted = true;
    for(uint32_t i = start; i < end; ++i) {
        if(data[i] > data[i + 1]) {
            is_sorted = false;
            break;
        }
    }
    return is_sorted;
}

static int32_t thanos_sort(const uint32_t *const data, const uint32_t start, const uint32_t end) {
    if(start < end) {
        if(check_sorted(data, start, end)) {
            return (int32_t) (1 + (end - start));
        }
        const uint32_t mid = ((end - start) >> 1) + start;
        return max(thanos_sort(data, mid + 1, end), thanos_sort(data, start, mid));
    }
    return 1;
}

static int32_t max(const int32_t a, const int32_t b) {
    return a > b ? a : b;
}


/*  Problem Statement: https://codeforces.com/problemset/problem/1145/A
 *  Author: striker
*/

#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
#include<stdbool.h>

#define NOT_POSSIBLE -1
#define CONSTRAINTS_OUT_OF_BOUND_ERROR(variable,constraints) fprintf(stderr,"Line number: %u: Constraint not satified. <%s> should be under the given constraints i.e %s.\n", __LINE__, #variable, #constraints)
#define MEMORY_ALLOCATION_FAILED_ERROR(variable,bytes) fprintf(stderr,"Line number: %u: Not able to allocate the memory to <%lu> bytes of memory to <%s> variable\n", __LINE__, (sizeof(variable) * bytes), #variable)

static bool check_sorted(const uint32_t *const,const uint32_t,const uint32_t);
static int32_t thanos_sort(const uint32_t *const,const uint32_t,const uint32_t); // Recursive Function.
static int32_t max(const int32_t,const int32_t);

int main(void) {
    uint32_t n;
    scanf("%u", &n);
    if(n & (n - 1)) {
        CONSTRAINTS_OUT_OF_BOUND_ERROR(n,"2^n");
        exit(0);
    }
    uint32_t *const data = calloc(n,sizeof(*data));
    if(data) {
        for(uint32_t i = 0; i < n; ++i) {
            scanf("%u", (data + i));
            if(data[i] < 1 || data[i] > 101) {
                CONSTRAINTS_OUT_OF_BOUND_ERROR(data[i],"1 <= data[i] <= 100");
                exit(0);
            }
        }
        printf("%d\n", thanos_sort(data,0,(n - 1)));
    } else {
        MEMORY_ALLOCATION_FAILED_ERROR(*data,n);
        exit(0);
    }
    return EXIT_SUCCESS;
}

static bool check_sorted(const uint32_t *const data,const uint32_t start,const uint32_t end) {
    bool is_sorted = true;
    for(uint32_t i = start; i < end; ++i) {
        if(data[i] > data[i + 1]) {
            is_sorted = false;
            break;
        }
    }
    return is_sorted;
}

static int32_t thanos_sort(const uint32_t *const data,const uint32_t start,const uint32_t end) {
    if(start == end) {
        return 1;
    } else if(start < end) {
        if(check_sorted(data,start,end)) {
            return (int32_t) (1 + (end - start));
        }
        const uint32_t mid = ((end - start) >> 1) + start;
        return max(thanos_sort(data,mid + 1,end),thanos_sort(data,start,mid));
    }
    return NOT_POSSIBLE;
}

static int32_t max(const int32_t a,const int32_t b) {
    return a > b ? a : b;
}


/*  Problem Statement: https://codeforces.com/problemset/problem/1145/A
 *  Author: striker
*/

#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
#include<stdbool.h>

#define NOT_POSSIBLE -1
#define CONSTRAINTS_OUT_OF_BOUND_ERROR(variable,constraints) fprintf(stderr,"Line number: %u: Constraint not satified. <%s> should be under the given constraints i.e %s.\n", __LINE__, #variable, #constraints)
#define MEMORY_ALLOCATION_FAILED_ERROR(variable,bytes) fprintf(stderr,"Line number: %u: Not able to allocate the memory to <%lu> bytes of memory to <%s> variable\n", __LINE__, (sizeof(variable) * bytes), #variable)

static bool check_sorted(const uint32_t *const,const uint32_t);
static int32_t thanos_sort(const uint32_t *const,const uint32_t,const uint32_t); // Recursive Function.

int main(void) {
    uint32_t n;
    scanf("%u", &n);
    if(n & (n - 1)) {
        CONSTRAINTS_OUT_OF_BOUND_ERROR(n,"2^n");
        exit(0);
    }
    uint32_t *const data = calloc(n,sizeof(*data));
    if(data) {
        for(uint32_t i = 0; i < n; ++i) {
            scanf("%u", (data + i));
            if(data[i] < 1 || data[i] > 101) {
                CONSTRAINTS_OUT_OF_BOUND_ERROR(data[i],"1 <= data[i] <= 100");
                exit(0);
            }
        }
        printf("%d\n", thanos_sort(data,0,(n - 1)));
    } else {
        MEMORY_ALLOCATION_FAILED_ERROR(*data,n);
        exit(0);
    }
    return EXIT_SUCCESS;
}

static bool check_sorted(const uint32_t *const data,uint32_t n) {
    bool is_sorted = true;
    for(uint32_t i = 0; i < (n - 1); ++i) {
        if(data[i] > data[i + 1]) {
            is_sorted = false;
            break;
        }
    }
    return is_sorted;
}

static int32_t thanos_sort(const uint32_t *const data,const uint32_t start,const uint32_t end) {
    if(start == end) {
        return 1;
    } else if(start <= end) {
        if(check_sorted(data,(end - start) + 1)) {
            return (int32_t) (1 + (end - start));
        }
        const uint32_t mid = ((end - start) >> 1) + start;
        return thanos_sort(data,start,mid);
    }
    return NOT_POSSIBLE;
}


#include <stdio.h>

int g(int a[], int n)
{
	int	i;
	int	sorted;
	int	left;
	int	right;

	sorted = 1;

	for (i = 1; i < n; i += 1) {
		if (a[i-1] > a[i]) {
			sorted = 0;
			break;
		}
	}

	if (sorted)
		return n;

	left = g(a, n/2);
	if (left == n/2)
		return left;
	right = g(a+n/2, n/2);
	if (left > right)
		return left;
	else
		return right;
}

int f(int n)
{
	int	a[n];
	int	i;
	int	x;

	for (i = 0; i < n; i += 1) {
		scanf("%d", &x);
		a[i] = x;
	}

	return g(a, n);
}

int main()
{
	int	n;
	int	x;

	scanf("%d\n", &n);

	x = f(n);

	printf("%d\n", x);

	return 0;
}


#include <stdio.h>

int a[20], k = 0;
void find(int s, int e)
{
	int i, j;
	for(i = s + 1; i < e; i++)
		if(a[i] < a[i - 1])break;
	if(i == e)
		k =  k > e - s ? k : e - s;
	else
	{
		find(s, (s + e) / 2);
		find((s + e) / 2, e);
	}
}

int main()
{
	int n, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &a[i]);
	find(0, n);
	printf("%d\n", k);
	return 0;
}


#include <stdio.h>

int a[20], k = 1;
int find(int s, int e)
{
	int i, j;
	for(i = s + 1; i < e; i++)
		if(a[i] < a[i - 1])break;
	if(i == e)return e - s;
	else
	{
		find(s, (s + e) / 2);
		find((s + e) / 2, e);
	}
}

int main()
{
	int n, i, j, s = 1;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &a[i]);
	printf("%d\n", find(0, n));
	return 0;
}


#include <stdio.h>

int a[20], k = 0;
void find(int s, int e)
{
	if(0 == k)
	{
		int i, j;
		for(i = s + 1; i < e; i++)
			if(a[i] < a[i - 1])break;
		if(i == e)
			k = e - s;
		else
		{
			find(s, (s + e) / 2);
			find((s + e) / 2, e);
		}
	}
}

int main()
{
	int n, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &a[i]);
	find(0, n);
	printf("%d\n", k);
	return 0;
}


#include<stdio.h>
int b=0;
void TS(int *a,int l)
{int z=0;
    if(l==0)
    return;

    for(int i=0;i<l-1;++i)
    if(a[i]>a[i+1])
      {
          z=1;
          break;
      }

    if(z==1)
    {
        TS(a+(l-1)/2,l/2);
        TS(a,l/2);
        return;
    }

    if(l>b)
    b=l;

}
int main()
{ int n;
    scanf("%d ",&n);
    int ar[n];
    for(int i=0;i<n;++i)
    scanf("%d",&ar[i]);

    TS(ar,n);
    printf("%d \n",b);

}


#include<stdio.h>
int b=0;
void TS(int *a,int l)
{int z=0;
    if(l==0)
    return;
  if(b>=l)
  return;
    for(int i=0;i<l-1;++i)
   { if(a[i]>a[i+1])
      {
          z=1;
          break;
      }}

    if(z==1)
    {
        TS(a+(l)/2,l/2);
        TS(a,l/2);
        return;
    }

    if(l>b)
    b=l;

}
int main()
{ int n;
    scanf("%d ",&n);
    int ar[n];
    for(int i=0;i<n;++i)
    scanf("%d",&ar[i]);

    TS(ar,n);
    printf("%d \n",b);

}


#include <stdio.h>
int arr[100];
int check(int arr[100],int len,int n){
	int flag = 0;
	for(int i = n-len+1;i<n && flag == 0;i++){
		if(arr[i]<arr[i-1]){
			flag = 1;
		}
	}
	return flag;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	int len = n;
	while(check(arr,len,n) != 0 && len != 1){
		len/=2;
	}
	printf("%d",len);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll ans=0;
    string s;
    cin>>s;
    if(s.size()==1)
    {
        //cout<<"hella";
        if((int(s[0]))%4==0)
        cout<<1;
        else
        cout<<0;
    }
    if(s[0]%4==0)
    ans++;
    for(ll i=1;i<s.size();i++)
    {
        if(((s[i]-48)+(s[i-1]-48)*10)%4==0)
        {
            ans=ans+i;
        }
        if(s[i]%4==0)
        ans++;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll ans=0;
    string s;
    cin>>s;
    if(s.size()==1)
    {
        //cout<<"hella";
        if((int(s[0]))%4==0)
        cout<<1;
        else
        cout<<0;
        continue;
    }
    if(s[0]%4==0)
    ans++;
    for(ll i=1;i<s.size();i++)
    {
        if(((s[i]-48)+(s[i-1]-48)*10)%4==0)
        {
            ans=ans+i;
        }
        if(s[i]%4==0)
        ans++;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int curr=0;
        int ans=0;
        int s[n],f[n];
        for(int i=0;i<n;i++)
            cin>>s[i]>>f[i];
        int i=0,j=0;
        sort(f,f+n);
        sort(s,s+n);
        while(i<n && j<n)
        {
            if(s[i]<f[j])
            {
                curr++;
                i++;
                ans=max(ans,curr);
            }
            else
            {
                curr--;
                j++;
            }
        }
        cout<<n-ans+1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll a=s[0]-'0';
    ll count=0;
    if(a%4==0)
        count++;
    for(ll i=1;i<s.length();i++)
    {
        ll b=s[i]-'0';
        if(b%4==0)
            count++;
        ll c=a*10+b;
        if(c%4==0)
            count+=i;
         a=b;
    }
    cout<<count<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll ans=0;
    ll prev=0;
    for(ll i=s.size()-1;i>=0;i--)
    {
        if((s[i]-'0')%4==0)
        {
            ans++;
        }
        if(i==s.size()-1)
        {
            prev=s[i]-'0';
            continue;
        }
        else
        {
            ll num=(s[i]-'0')*10+prev;
            if(num%4==0)
            {
              ans++;
              ans+=i;
            }
            prev=s[i];
        }
    }

cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define MCQUEEN ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;

// author-->shivam_0105

int main()
{
    MCQUEEN

    string s;
    cin>>s;
    unsigned ll n = s.size();
    unsigned ll c=0;
    for ( int i=0 ; i<n ; i++ )
    {
        int a = s[i]-'0';
        if ( a%4==0 )
        {
            c+=1;
        }
    }

    for ( int i=0 ; i<n-1 ; i++ )
    {
        unsigned ll a = s[i]-'0';
        unsigned ll b = s[i+1]-'0';

        unsigned ll d = (10*a) + b;
        if ( d%4==0 )
        {
            c+=(i+1);
        }
    }

    cout<<c<<endl;

    //cout <<endl<<endl<< 1.0 * clock() / CLOCKS_PER_SEC <<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MCQUEEN ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;

// author-->shivam_0105

int main()
{
    MCQUEEN

    string s;
    cin>>s;
    int n = s.size();
    int c=0;
    for ( int i=0 ; i<n ; i++ )
    {
        int a = s[i]-'0';
        if ( a%4==0 )
        {
            c+=1;
        }
    }

    for ( int i=0 ; i<n-1 ; i++ )
    {
        unsigned ll a = s[i]-'0';
        unsigned ll b = s[i+1]-'0';

        unsigned ll d = (10*a) + b;
        if ( d%4==0 )
        {
            c+=(i+1);
        }
    }

    cout<<c<<endl;

    //cout <<endl<<endl<< 1.0 * clock() / CLOCKS_PER_SEC <<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MCQUEEN ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;

// author-->shivam_0105

int main()
{
    MCQUEEN

    string s;
    cin>>s;
    int n = s.size();
    int c=0;
    for ( int i=0 ; i<n ; i++ )
    {
        int a = s[i]-'0';
        if ( a%4==0 )
        {
            c+=1;
        }
    }

    for ( int i=0 ; i<n-1 ; i++ )
    {
        int a = s[i]-'0';
        int b = s[i+1]-'0';

        int d = (10*a) + b;
        if ( d%4==0 )
        {
            c+=(i+1);
        }
    }

    cout<<c<<endl;

    //cout <<endl<<endl<< 1.0 * clock() / CLOCKS_PER_SEC <<endl;
    return 0;
}


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

#define ll long long

int main() {
	// your code goes here
	string s;
	cin>>s;
	ll ans=0,dp[2][s.length()+1]={0};
	for(ll i=1;i<=s.length();i++)
	{
		for(ll j=1;j<=i;j++)
		{
			    if(i%2!=0)
				{dp[1][j]=s[i-1]-'0'+10*dp[0][j-1];
				if(dp[1][j]%4==0)
				ans++;}
				else
				{
					dp[0][j]=s[i-1]-'0'+10*dp[1][j-1];
				if(dp[0][j]%4==0)
				ans++;
				}

		}
	}
	cout<<ans;
	return 0;
}


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

#define ll long long

int main() {
	// your code goes here
	string s;
	cin>>s;
	ll ans=0,dp[s.length()+1][s.length()+1]={0};
	for(ll i=1;i<=s.length();i++)
	{
		for(ll j=1;j<=i;j++)
		{

				dp[i][j]=s[i-1]-'0'+10*dp[i-1][j-1];
				if(dp[i][j]%4==0)
				ans++;

		}
	}
	cout<<ans;
	return 0;
}


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

#define ll long long

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	// your code goes here
	string s;
	cin>>s;
	ll ans=0,dp[2][s.length()+1]={0};
	for(ll i=1;i<=s.length();i++)
	{
		for(ll j=1;j<=i;j++)
		{
			    if(i%2!=0)
				{dp[1][j]=s[i-1]-'0'+10*dp[0][j-1];
				if(dp[1][j]%4==0)
				ans++;}
				else
				{
					dp[0][j]=s[i-1]-'0'+10*dp[1][j-1];
				if(dp[0][j]%4==0)
				ans++;
				}

		}
	}
	cout<<ans;
	return 0;
}


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

#define ll long long

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	// your code goes here
	string s;
	cin>>s;
	ll ans=0,a=s[0]-'0';
	for(ll i=0;i<s.length();i++)
	{
		if((s[i]-'0')%4==0)
		ans++;
		if(i==0);
		else
		{
		    if((10*a+s[i]-'0')%4==0)
		    ans+=i;
		}
		a=s[i]-'0';
	}
	cout<<ans;
	return 0;
}


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

#define ll long long

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	// your code goes here
	string s;

	cin>>s;
	ll ans=0,dp[2][s.length()+1]={0};
	for(ll i=1;i<=s.length();i++)
	{
		for(ll j=1;j<=i;j++)
		{
			    if(i%2!=0)
				{dp[1][j]=s[i-1]-'0'+10*dp[0][j-1];
				if(dp[1][j]%4==0)
				ans++;}
				else
				{
					dp[0][j]=s[i-1]-'0'+10*dp[1][j-1];
				if(dp[0][j]%4==0)
				ans++;
				}

		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
string s;getline(cin,s);
int nOne=0;
int size=s.size();
for(int i=0;i<size;++i){
string t=s.substr(i,1);
stringstream ss(t);
int a;ss>>a;
if(a%4==0){++nOne;}
}
if(size<2){cout<<nOne<<"\n";return 0;}
int cRest=0;
for(int i=size-1;i>=1;--i){
string t=s.substr(i-1,2);
stringstream ss(t);
int p;ss>>p;
if(p%4==0){cRest+=i;}
}
cout<<nOne+cRest<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
string s;cin>>s;int size=s.size();
ll result=0;
for(int i=size-1;i>=0;--i){
string p=s.substr(i,1);
stringstream ss1(p);int m;ss1>>m;
if(m%4==0){++result;}
if(i>=1){
string t=s.substr(i-1,2);
stringstream ss(t);int n;ss>>n;
if(n%4==0){result+=(1+i-1);}}
}
cout<<result<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
string s;getline(cin,s);
int nOne=0;
int size=s.size();
for(int i=0;i<size;++i){
string t=s.substr(i,1);
stringstream ss(t);
int a;ss>>a;
if(a%4==0){++nOne;}
}
if(size<2){cout<<nOne<<"\n";return 0;}
ll cRest=0;
for(int i=size-1;i>=1;--i){
string t=s.substr(i-1,2);
stringstream ss(t);
int p;ss>>p;
if(p%4==0){cRest+=i;}
}
cout<<nOne+cRest<<"\n";
}


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

int main(){
    char s[300005];
    scanf("%s",&s);
    long long int cnt=0,i,j,p=strlen(s);
    for(i=0;i<p;i++){
        if((s[i]-'0')%4==0)
            cnt++;
    }

    for(i=0;i<p-1;i++){
        if(((s[i]-'0')*10+(s[i+1]-'0'))%4==0)
            cnt+=i+1;
    }

    printf("%d",cnt);
    return 0;
}


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

int main(){
    char s[300005];
    scanf("%s",&s);
    long long int cnt=0,i,j;
    for(i=0;i<strlen(s);i++){
        if((s[i]-'0')%4==0)
            cnt++;
    }

    for(i=0;i<strlen(s)-1;i++){
        if(((s[i]-'0')*10+(s[i+1]-'0'))%4==0)
            cnt+=i+1;
    }

    printf("%d",cnt);
    return 0;
}


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

int main(){
    char s[300005];
    scanf("%s",&s);
    long long int cnt=0,i,j,p=strlen(s)-1;
    for(i=0;i<strlen(s);i++){
        if((s[i]-'0')%4==0)
            cnt++;
    }

    for(i=0;i<p;i++){
        if(((s[i]-'0')*10+(s[i+1]-'0'))%4==0)
            cnt+=i+1;
    }

    printf("%I64d",cnt);
    return 0;
}


#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define pii pair <int, int>
#define pcc pair <char, char>
#define mp make_pair
#define ll long long
#define pb push_back
#define pll pair <ll, ll>

#define PI 3.1415926535897932384626433832795
#define P 1103
#define SZ 10000009
#define INF (1e9+7)
#define mod (1000000007)

using namespace std;
typedef long double ld;
typedef unsigned long long ull;

int f (int l, int r);

string s;
int ans;

int main()
{
//	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
//	cout.precision(15);
//	cout.setf(ios::fixed, ios:: floatfield);

    cin >> s;
    if (s[0]=='4' || s[0]=='8' || s[0]=='0') ++ans;
    for (int i=s.size()-1; i>=1; --i)
    {
        int t=atoi((s.substr(i-1, 2)).c_str());
        if (!(t%4))
            ans+=i;
        if (s[i]=='4' || s[i]=='8' || s[i]=='0')
            ++ans;

    }
    printf("%d", ans);
    return 0;
}


#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define pii pair <int, int>
#define pcc pair <char, char>
#define mp make_pair
#define ll long long
#define pb push_back
#define pll pair <ll, ll>

#define PI 3.1415926535897932384626433832795
#define P 1103
#define SZ 10000009
#define INF (1e9+7)
#define mod (1000000007)

using namespace std;
typedef long double ld;
typedef unsigned long long ull;

int f (int l, int r);

string s;
ll ans;

int main()
{
//	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
//	cout.precision(15);
//	cout.setf(ios::fixed, ios:: floatfield);

    cin >> s;
    if (s[0]=='4' || s[0]=='8' || s[0]=='0') ++ans;
    for (int i=s.size()-1; i>=1; --i)
    {
        int t=atoi((s.substr(i-1, 2)).c_str());
        if (!(t%4))
            ans+=i;
        if (s[i]=='4' || s[i]=='8' || s[i]=='0')
            ++ans;

    }
    printf("%I64d", ans);
    return 0;
}


#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define pii pair <int, int>
#define pcc pair <char, char>
#define mp make_pair
#define ll long long
#define pb push_back
#define pll pair <ll, ll>

#define PI 3.1415926535897932384626433832795
#define P 1103
#define SZ 10000009
#define INF (1e9+7)
#define mod (1000000007)

using namespace std;
typedef long double ld;
typedef unsigned long long ull;

int f (int l, int r);

string s;
ll ans;

int main()
{
//	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
//	cout.precision(15);
//	cout.setf(ios::fixed, ios:: floatfield);

    cin >> s;
    if (s[0]=='4' || s[0]=='8' || s[0]=='0') ++ans;
    for (int i=s.size()-1; i>=1; --i)
    {
        int t=atoi((s.substr(i-1, 2)).c_str());
        if (!(t%4))
            ans+=i;
        if (s[i]=='4' || s[i]=='8' || s[i]=='0')
            ++ans;

    }
    printf("%d", ans);
    return 0;
}


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

int main(){
string s;
cin>>s;
int count=0;
int l=s.length();
for(int i=1;i<l;i++){
    int n=(s[i-1]-'0')*10+(s[i]-'0');
    if(n%4==0){
        count+=i;
    }
    if((s[i-1]-'0')%4==0){
    count++;
    }
}
if((s[l-1]-'0')%4==0){
count++;
}
cout<<count;
}


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

int main(){
string s;
cin>>s;
long long nt count=0;
long long int l=s.length();
for(int i=1;i<l;i++){
    int n=(s[i-1]-'0')*10+(s[i]-'0');
    if(n%4==0){
        count+=i;
    }
    if((s[i-1]-'0')%4==0){
    count++;
    }
}
if((s[l-1]-'0')%4==0){
count++;
}
cout<<count;
}


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

int main(){
string s;
cin>>s;
long long int count=0;
long long int l=s.length();
for(int i=1;i<l;i++){
    int n=(s[i-1]-'0')*10+(s[i]-'0');
    if(n%4==0){
        count+=i;
    }
    if((s[i-1]-'0')%4==0){
    count++;
    }
}
if((s[l-1]-'0')%4==0){
count++;
}
cout<<count;
}


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

int main()
{
   long long n,m,i,j,x,y,k=0;
   string s;
   cin>>s;
   vector<long long>a(s.size());
   for(i=0; i<s.size();i++)
     for(j=i; j>=0; j--)
      {
          a[j]=(a[j]*10+s[i]-48)%4;
          if(a[i]==0)
           k++:
      }
    cout<<k<<endl;
}


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

int main()
{
   long long n,m,i,j,k=0;
   string s;
   cin>>s;
   vector<long long>a(s.size());
   for(i=0; i<s.size();i++)
     for(j=i; j>=0; j--)
      {
          a[j]=(a[j]*10+s[i]-48)%4;
          if(a[j]==0)
           k++;
      }
    cout<<k<<endl;
}


#include <bits/stdc++.h>
/*
  _   _     _____    __  __    ____      ______    ______      ___     ______
 /'\_/`\  /\  __`\  /\ \/\ \  /\  _`\   /\__  _\  /\  _  \    /'___\  /\  _  \
/\      \ \ \ \/\ \ \ \ \ \ \ \ \,\L\_  \/_/\ \/  \ \ \L\ \  /\ \__/  \ \ \L\ \
\ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \/_\__ \    \ \ \   \ \  __ \ \ \ ,__\  \ \  __ \
 \ \ \_/\ \ \ \ \_\ \ \ \ \_/ \  /\ \L\ \   \ \ \   \ \ \/\ \ \ \ \_/   \ \ \/\ \
  \ \_\\ \_\ \ \_____\ \ `\___/  \ `\____\   \ \_\   \ \_\ \_\ \ \_\     \ \_\ \_\
   \/_/ \/_/  \/_____/  `\/__/    \/_____/    \/_/    \/_/\/_/  \/_/      \/_/\/_/
  __ __
 _\ \\ \__
/\__  _  _\
\/_L\ \\ \L_
  /\_   _  _\
  \/_/\_\\_\/
     \/_//_/
*/
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ld long double
#define EPS (1e-15)
#define mod 1000000007
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define SIZE(x) (int) x.size()
#define to_string(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
#define lp(i, a, n) for (int(i) = (a); (i) <= (int)(n); ++(i))
#define lpd(i, n, a) for (int(i) = (n); (i) >= (a); --(i))
#define bitcount(n) __builtin_popcountll(n)
#define readi(x) scanf("%d", &x);
#define readl(x) scanf("%lld", &x);
#define reads(x) scanf("%s", &x);
#define readc(x) scanf("%c", &x);
#define readd(x) scanf("%lf", &x);

using namespace std;
const int N = 1000006;
const int K = (int)log2(N) + 2;
const int SQRTN = (int) sqrt(N) + 7;
const ll infi = 1ll << 60;
ll n, ans;
string s;
vector<string> vec;

bool ok(string str) {
    for (auto cur : vec)
        if (str == cur)
            return true;
    return false;
}

bool is_div(int x) {
    return x % 4 == 0;
}

int main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
    io;
    cin >> s;
    lp (i, 0, 99) {
        if (i % 4 == 0) {
            string div = to_string(i);
            if (SIZE(div) == 1)
                div = "0" + div;
            vec.push_back(div);
        }
    }
    ans = is_div(s[0] - '0');
    if (SIZE(s) == 1)
        return cout << ans << endl, 0;
    lpd (i, SIZE(s) - 1, 1) {
        ans += is_div(s[i] - '0');
        string cur = "";
        cur += s[i - 1];
        cur += s[i];
        if (ok(cur))
            ans += i;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
/*
  _   _     _____    __  __    ____      ______    ______      ___     ______
 /'\_/`\  /\  __`\  /\ \/\ \  /\  _`\   /\__  _\  /\  _  \    /'___\  /\  _  \
/\      \ \ \ \/\ \ \ \ \ \ \ \ \,\L\_  \/_/\ \/  \ \ \L\ \  /\ \__/  \ \ \L\ \
\ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \/_\__ \    \ \ \   \ \  __ \ \ \ ,__\  \ \  __ \
 \ \ \_/\ \ \ \ \_\ \ \ \ \_/ \  /\ \L\ \   \ \ \   \ \ \/\ \ \ \ \_/   \ \ \/\ \
  \ \_\\ \_\ \ \_____\ \ `\___/  \ `\____\   \ \_\   \ \_\ \_\ \ \_\     \ \_\ \_\
   \/_/ \/_/  \/_____/  `\/__/    \/_____/    \/_/    \/_/\/_/  \/_/      \/_/\/_/
  __ __
 _\ \\ \__
/\__  _  _\
\/_L\ \\ \L_
  /\_   _  _\
  \/_/\_\\_\/
     \/_//_/
*/
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ld long double
#define EPS (1e-15)
#define mod 1000000007
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define SIZE(x) (int) x.size()
#define to_string(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
#define lp(i, a, n) for (int(i) = (a); (i) <= (int)(n); ++(i))
#define lpd(i, n, a) for (int(i) = (n); (i) >= (a); --(i))
#define bitcount(n) __builtin_popcountll(n)
#define readi(x) scanf("%d", &x);
#define readl(x) scanf("%lld", &x);
#define reads(x) scanf("%s", &x);
#define readc(x) scanf("%c", &x);
#define readd(x) scanf("%lf", &x);

using namespace std;
const int N = 1000006;
const int K = (int)log2(N) + 2;
const int SQRTN = (int) sqrt(N) + 7;
const ll infi = 1ll << 60;
int n, ans;
string s;
vector<string> vec;

bool ok(string str) {
    for (auto cur : vec)
        if (str == cur)
            return true;
    return false;
}

bool is_div(int x) {
    return x % 4 == 0;
}

int main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
    io;
    cin >> s;
    lp (i, 0, 99) {
        if (i % 4 == 0) {
            string div = to_string(i);
            if (SIZE(div) == 1)
                div = "0" + div;
            vec.push_back(div);
        }
    }
    ans = is_div(s[0] - '0');
    if (SIZE(s) == 1)
        return cout << ans << endl, 0;
    lpd (i, SIZE(s) - 1, 1) {
        ans += is_div(s[i] - '0');
        string cur = "";
        cur += s[i - 1];
        cur += s[i];
        if (ok(cur))
            ans += i;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
/*
  _   _     _____    __  __    ____      ______    ______      ___     ______
 /'\_/`\  /\  __`\  /\ \/\ \  /\  _`\   /\__  _\  /\  _  \    /'___\  /\  _  \
/\      \ \ \ \/\ \ \ \ \ \ \ \ \,\L\_  \/_/\ \/  \ \ \L\ \  /\ \__/  \ \ \L\ \
\ \ \__\ \ \ \ \ \ \ \ \ \ \ \ \/_\__ \    \ \ \   \ \  __ \ \ \ ,__\  \ \  __ \
 \ \ \_/\ \ \ \ \_\ \ \ \ \_/ \  /\ \L\ \   \ \ \   \ \ \/\ \ \ \ \_/   \ \ \/\ \
  \ \_\\ \_\ \ \_____\ \ `\___/  \ `\____\   \ \_\   \ \_\ \_\ \ \_\     \ \_\ \_\
   \/_/ \/_/  \/_____/  `\/__/    \/_____/    \/_/    \/_/\/_/  \/_/      \/_/\/_/
  __ __
 _\ \\ \__
/\__  _  _\
\/_L\ \\ \L_
  /\_   _  _\
  \/_/\_\\_\/
     \/_//_/
*/
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ld long double
#define EPS (1e-15)
#define mod 1000000007
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define SIZE(x) (int) x.size()
#define to_string(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
#define lp(i, a, n) for (int(i) = (a); (i) <= (int)(n); ++(i))
#define lpd(i, n, a) for (int(i) = (n); (i) >= (a); --(i))
#define bitcount(n) __builtin_popcountll(n)
#define readi(x) scanf("%d", &x);
#define readl(x) scanf("%lld", &x);
#define reads(x) scanf("%s", &x);
#define readc(x) scanf("%c", &x);
#define readd(x) scanf("%lf", &x);

using namespace std;
const int N = 1000006;
const int K = (int)log2(N) + 2;
const int SQRTN = (int) sqrt(N) + 7;
const ll infi = 1ll << 60;
ll n, ans;
string s;
vector<string> vec;

bool ok(string str) {
    for (auto cur : vec)
        if (str == cur)
            return true;
    return false;
}

bool is_div(int x) {
    return x % 4 == 0;
}

int main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
    io;
    cin >> s;
    lp (i, 0, 99) {
        if (i % 4 == 0) {
            string div = to_string(i);
            if (SIZE(div) == 1)
                div = "0" + div;
            vec.push_back(div);
        }
    }
    ans = is_div(s[0] - '0');
    lpd (i, SIZE(s) - 1, 1) {
        ans += is_div(s[i] - '0');
        string cur = "";
        cur += s[i - 1];
        cur += s[i];
        if (ok(cur))
            ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    string str;
    cin >> str;

    ll cnt = 0;
    for (int i = 0; i < str.size(); ++i) {
        for (int j = 1; j <= str.size() - i; ++j) {
            if(j >= 2) {
                cnt += stoi(str.substr(i + j - 2, 2)) % 4 == 0;
            } else if(j == 1){
                cnt += stoi(str.substr(i, j)) % 4 == 0;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string str;
    cin >> str;

    ll cnt = 0;
    for (int i = 0; i < str.size(); ++i) {
        for (int j = 1; j <= str.size() - i; ++j) {
            if(j >= 2) {
                cnt += stoi(str.substr(i + j - 2, 2)) % 4 == 0;
            } else if(j == 1){
                cnt += stoi(str.substr(i, j)) % 4 == 0;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    string str;
    cin >> str;
    map<string, int> subs;

    for (int i = 0; i < str.size(); ++i) {
        for (int j = 1; j <= str.size() - i; ++j) {
            subs[str.substr(i, j)]++;
        }
    }

    ll cnt = 0;
    for (auto &i : subs) {
        if (i.fi.size() >= 2) {
            cnt += (stoi(i.fi.substr(i.fi.size() - 2, 2)) % 4 == 0) * i.se;
        } else if (i.fi.size() == 1) {
            cnt += (stoi(i.fi) % 4 == 0) * i.se;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string str;
    cin >> str;

    ll cnt = 0;
    for (int i = 0; i < str.size(); ++i) {
        for (int j = 1; j <= str.size() - i; ++j) {
            if(j >= 2) {
                cnt += ( (str[i + j - 2] - '0') * 10 + (str[i + j - 1] - '0') ) % 4 == 0;
            } else if(j == 1){
                cnt += (str[i + j - 1] - '0') % 4  == 0;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    string str;
    cin >> str;

    ll cnt = 0;
    for (int i = 0; i < str.size(); ++i) {
        for (int j = 1; j <= str.size() - i; ++j) {
            string sub = str.substr(i, j);
            if (j >= 2) {
                cnt += stoi(sub.substr(sub.size() - 2, 2)) % 4 == 0;
            } else if (j == 1) {
                cnt += stoi(sub) % 4 == 0;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string str;
    cin >> str;

    ll cnt = 0;
    for (int i = 0; i < str.size(); ++i) {
        if (i >= 1)
            cnt += (((str[i - 1] - '0') * 10 + (str[i] - '0')) % 4 == 0) * i;

        cnt += (str[i] - '0') % 4 == 0;
    }

    cout << cnt << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(ll i=0;i<n;i++)
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define mp map<ll,ll>
#define ump unordered_map<ll,ll>
#define st set<ll>
#define mst multiset<ll>
#define pq priority_queue
#define mpq priority_queue<ll,vector<ll>,grater<ll> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void prllArray(ll arr[],ll n)
{
   for(ll i=0;i<n;i++)cout<<arr[i]<<' ';
}
void prllMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void prllUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void prllSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void prllMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void prllVec(vector<ll>v)
{
for(ll i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void prllVec2(vector<ll>v[],ll n)
{
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
int main()
{
    fastio
    string s;
       cin>>s;
    ll ans=0;
    for(ll i=0;i<s.size();i++)
    {
        ll t=s[i]-'0';
        if(t%4==0)ans++;
        if(i!=0)
        {
            ll num=(s[i-1]-'0')*10+(s[i]-'0');
            if(num%4==0)
                ans+=i;
        }
    }cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,grater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
int main()
{
    fastio
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        int t=s[i]-'0';
        if(t%4==0)ans++;
        if(i!=0)
        {
            int num=(s[i-1]-'0')*10+(s[i]-'0');
            if(num%4==0)
                ans+=i;
        }
    }cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(ll i=0;i<n;i++)
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define mp map<ll,ll>
#define ump unordered_map<ll,ll>
#define st set<ll>
#define mst multiset<ll>
#define pq priority_queue
#define mpq priority_queue<ll,vector<ll>,grater<ll> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void prllArray(ll arr[],ll n)
{
   for(ll i=0;i<n;i++)cout<<arr[i]<<' ';
}
void prllMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void prllUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void prllSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void prllMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void prllVec(vector<ll>v)
{
for(ll i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void prllVec2(vector<ll>v[],ll n)
{
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
int main()
{
    fastio
    cin>>s;
    string s;
    ll ans=0;
    for(ll i=0;i<s.size();i++)
    {
        ll t=s[i]-'0';
        if(t%4==0)ans++;
        if(i!=0)
        {
            ll num=(s[i-1]-'0')*10+(s[i]-'0');
            if(num%4==0)
                ans+=i;
        }
    }cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pb(a) push_back(a)
#define ll long long
#define oo 1000000007
#define maxN 100005
using namespace std;

ll dp[maxN];
string s;
int main() {
    //freopen("628B.inp", "r", stdin);
    //freopen("628B.out", "w", stdout);
    s = "-";
    string x;
    cin >> x;
    s += x;
    if( (s[1] - '0') % 4 == 0) dp[1] = 1;
    if( (s[2] - '0') % 4 == 0) dp[2] = dp[1] + 1;
    int c = ((s[1] - '0') * 10 + (s[2] - '0'));
    if(c % 4 == 0) dp[2] += 1;
    if(dp[2] < dp[1]) dp[2] = dp[1];
    fto(i, 3, (int)s.size() - 1) {
        if((s[i] - '0') % 4 == 0) dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
        int c = (s[i-1] - '0') * 10 + (s[i] - '0');
        if(c % 4 == 0) {
            dp[i] += 1;
            dp[i] += i - 2;
        }
    }
    cout << dp[s.size()-1];
    return 0;
}


#include<bits/stdc++.h>
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pb(a) push_back(a)
#define ll long long
#define oo 1000000007
#define maxN 100005
using namespace std;

ll dp[maxN];
string s;
int main() {
    //freopen("628B.inp", "r", stdin);
    //freopen("628B.out", "w", stdout);
    s = "-";
    string x;
    cin >> x;
    s += x;
    if( (s[1] - '0') % 4 == 0) dp[1] = 1;
    if( (s[2] - '0') % 4 == 0) dp[2] = dp[1] + 1;;
    int c = ((s[1] - '0') * 10 + (s[2] - '0'));
    if(c % 4 == 0) dp[2] += 1;
    fto(i, 3, (int)s.size() - 1) {
        if(s[i] % 4 == 0) dp[i] = dp[i-1] + 1;
        int c = (s[i-1] - '0') * 10 + (s[i] - '0');
        if(c % 4 == 0)
            dp[i] += i-1;
        if(dp[i] < dp[i-1]) dp[i] = dp[i-1];
    }
    cout << dp[s.size()-1];
    return 0;
}


#include<bits/stdc++.h>
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pb(a) push_back(a)
#define ll long long
#define oo 1000000007
#define maxN 100005
using namespace std;

ll dp[maxN];
string s;
int main() {
    //freopen("628B.inp", "r", stdin);
    //freopen("628B.out", "w", stdout);
    s = "-";
    string x;
    cin >> x;
    s += x;
    if( (s[1] - '0') % 4 == 0) dp[1] = 1;
    if( (s[2] - '0') % 4 == 0) dp[2] = dp[1] + 1;;
    int c = ((s[1] - '0') * 10 + (s[2] - '0'));
    if(c % 4 == 0) dp[2] += 1;
    if(dp[2] < dp[1]) dp[2] = dp[1];
    fto(i, 3, (int)s.size() - 1) {
        if(s[i] % 4 == 0) dp[i] = dp[i-1] + 1;
        int c = (s[i-1] - '0') * 10 + (s[i] - '0');
        if(c % 4 == 0)
            dp[i] += i-1;
        if(dp[i] < dp[i-1]) dp[i] = dp[i-1];
    }
    cout << dp[s.size()-1];
    return 0;
}


#include<bits/stdc++.h>
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pb(a) push_back(a)
#define ll long long
#define oo 1000000007
#define maxN 300005
using namespace std;

ll dp[maxN];
string s;
int main() {
    //freopen("628B.inp", "r", stdin);
    //freopen("628B.out", "w", stdout);
    s = "-";
    string x;
    cin >> x;
    s += x;
    if( (s[1] - '0') % 4 == 0) dp[1] = 1;
    if( (s[2] - '0') % 4 == 0) dp[2] = dp[1] + 1;
    int c = ((s[1] - '0') * 10 + (s[2] - '0'));
    if(c % 4 == 0) dp[2] += 1;
    if(dp[2] < dp[1]) dp[2] = dp[1];
    fto(i, 3, (int)s.size() - 1) {
        if((s[i] - '0') % 4 == 0) dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
        int c = (s[i-1] - '0') * 10 + (s[i] - '0');
        if(c % 4 == 0) {
            dp[i] += 1;
            dp[i] += i - 2;
        }
    }
    cout << dp[s.size()-1];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

void solve()
{
   string s;cin>>s;ll c=0;
   for(ll i=0;i<s.length();i++)
   {
       ll p=s[i]-'0';
       if((p%4)==0)
        c++;
   }
   for(ll i=0;i<s.length()-1;i++)
   {
       ll p1=s[i]-'0';
       ll p2=s[i+1]-'0';
       ll r=(10*p1)+p2;
       if((r%4)==0)

       {
           c+=(i+1);
       }

   }
   cout<<c<<"\n";
}
int main()
{
    ll t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

void solve()
{
   string s;cin>>s;ll c=0;
   for(ll i=0;i<s.length();i++)
   {
       ll p=s[i]-'0';
       if((p%4)==0)
        c++;
   }
   for(ll i=0;i<(s.length()-1);i++)
   {
       ll p1=s[i]-'0';
       ll p2=s[i+1]-'0';
       ll r=(10*p1)+p2;
       if((r%4)==0)
       {
           c+=(i+1);
       }

   }
   cout<<c<<"\n";
}
int main()
{
    ll t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

void solve()
{
   string s;cin>>s;ll c=0;
   for(ll i=0;i<s.length();i++)
   {
       ll p=s[i]-'0';
       if((p%4)==0)
        c++;
   }
   for(ll i=0;i<(s.length()-1);i++)
   {
       ll p1=s[i]-'0';
       ll p2=s[i+1]-'0';
       ll r=(10*p1)+p2;
       if((r%4)==0)
       {
           c+=(i+1);
       }

   }
   cout<<c<<"\n";
}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

void solve()
{
   string s;cin>>s;ll c=0;
   for(ll i=0;i<s.length();i++)
   {
       ll p=s[i]-'0';
       if((p%4)==0)
        c++;
   }
   for(ll i=0;i<s.length()-1;i++)
   {
       ll p1=s[i]-'0';
       ll p2=s[i+1]-'0';
       ll r=(10*p1)+p2;
       if((r%4)==0)
       {
           c+=(i+1);
       }

   }
   cout<<c<<"\n";
}
int main()
{
    ll t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//typedef __int128 tll;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin >> s;
    vector<int> dp(s.size(), 0);
    int gud = stoi(s.substr(0, 1));
    dp[1] = dp[0] = (gud % 4 == 0) ;
    int soalo = stoi(s.substr(1, 1));
    int duao = stoi(s.substr(1 - 1, 2));
    dp[1] += (soalo % 4 == 0 ? 1 : 0) + (duao % 4 == 0 ? 1 : 0);
    for (int i = 2; i < s.size(); i++) {
        dp[i] = dp[i - 1];
        int solo = stoi(s.substr(i, 1));
        int duo = stoi(s.substr(i - 1, 2));
        int trio = stoi(s.substr(i - 2, 3));
        if (solo % 4 == 0) dp[i]++;
        if (duo % 4 == 0) dp[i]++;
        if (trio % 4 == 0) dp[i]++;
    }
    cout << dp[s.size() - 1];
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//typedef __int128 tll;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin >> s;
    vector<ll> dp(s.size(), 0);
    int gud = stoi(s.substr(0, 1));
    dp[0] = (gud % 4 == 0) ;
    for (int i = 1; i < s.size(); i++) {
        dp[i] = dp[i - 1];
        int solo = stoi(s.substr(i, 1));
        int duo = stoi(s.substr(i - 1, 2));
        if (solo % 4 == 0) dp[i]++;
        if (duo % 4 == 0) dp[i] += i;
    }
    cout << dp[s.size() - 1];
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//typedef __int128 tll;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin >> s;
    vector<int> dp(s.size(), 0);
    int gud = stoi(s.substr(0, 1));
    dp[1] = dp[0] = (gud % 4 == 0) ;
    int soalo = stoi(s.substr(1, 1));
    int duao = stoi(s.substr(1 - 1, 2));
    dp[1] += (soalo % 4 == 0 ? 1 : 0) + (duao % 4 == 0 ? 1 : 0);
    for (int i = 2; i < s.size(); i++) {
        dp[i] = dp[i - 1];
        int solo = stoi(s.substr(i, 1));
        int duo = stoi(s.substr(i - 1, 2));
        if (solo % 4 == 0) dp[i]++;
        if (duo % 4 == 0) dp[i] += i;
    }
    cout << dp[s.size() - 1];
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//typedef __int128 tll;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin >> s;
    vector<ll> dp(s.size(), 0);
    int gud = stoi(s.substr(0, 1));
    dp[0] = (gud % 4 == 0) ;
    int soalo = stoi(s.substr(1, 1));
    int duao = stoi(s.substr(1 - 1, 2));
    for (int i = 1; i < s.size(); i++) {
        dp[i] = dp[i - 1];
        int solo = stoi(s.substr(i, 1));
        int duo = stoi(s.substr(i - 1, 2));
        if (solo % 4 == 0) dp[i]++;
        if (duo % 4 == 0) dp[i] += i;
    }
    cout << dp[s.size() - 1];
}


import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Edu_1 {
	public static void main(String[] args){
		FasterScanner in=new FasterScanner();
		String s=in.nextLine();
		long ans=0;
		for(int i=0;i<s.length();i++){
			int c=s.charAt(i)-'0';
			if(c%4==0){
				ans++;
			}
			if(i+1<s.length()){
				int u=s.charAt(i+1)-'0';
				int check=10*c+u;
				//System.out.println(check);
				if(check%4==0){
					ans+=i+1;
				}
			}
		}
		System.out.println(ans);
	}

	static class FasterScanner {

	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;

	    public int read() {
	        if (numChars == -1) {
	            throw new InputMismatchException();
	        }
	        if (curChar >= numChars) {
	            curChar = 0;
	            try {
	                numChars = System.in.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0) {
	                return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public String nextLine() {
	        int c = read();
	        while (isSpaceChar(c)) {
	            c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isEndOfLine(c));
	        return res.toString();
	    }

	    public String nextString() {
	        int c = read();
	        while (isSpaceChar(c)) {
	            c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public long nextLong() {
	        int c = read();
	        while (isSpaceChar(c)) {
	            c = read();
	        }
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9') {
	                throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int nextInt() {
	        int c = read();
	        while (isSpaceChar(c)) {
	            c = read();
	        }
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9') {
	                throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int[] arr = new int[n];
	        for (int i = 0; i < n; i++) {
	            arr[i] = nextInt();
	        }
	        return arr;
	    }

	    public long[] nextLongArray(int n) {
	        long[] arr = new long[n];
	        for (int i = 0; i < n; i++) {
	            arr[i] = nextLong();
	        }
	        return arr;
	    }

	    private boolean isSpaceChar(int c) {
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    private boolean isEndOfLine(int c) {
	        return c == '\n' || c == '\r' || c == -1;
	    }
	}

}


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

public class CF628B{

	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	private static void soln(){
		String str = nextToken();
		long sum = 0;
		if(str.charAt(0)=='4' || str.charAt(0)=='8' || str.charAt(0)=='0')
			sum++;
		for (int i =1; i<str.length(); i++) {
			if(str.charAt(i)=='4' || str.charAt(i)=='8' || str.charAt(i) == '0'){
				sum++;
			}
			if(Integer.parseInt(str.substring(i-1,i+1))%4 == 0)
				sum += i;
		}
		pw.println(sum);
	}
	public static void main(String[] args){
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods

	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nextInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nextLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

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

}