Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which he had calculated. The only thing he knows is that the number is divisible by 4.

You are given a string s consisting of digits (the number on the display of the calculator after Yusuf randomly pressed the keys). Your task is to find the number of substrings which are divisible by 4. A substring can start with a zero.

A substring of a string is a nonempty sequence of consecutive characters.

For example if string s is 124 then we have four substrings that are divisible by 4: 12, 4, 24 and 124. For the string 04 the answer is three: 0, 4, 04.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.


-----Input-----

The only line contains string s (1 ≤ |s| ≤ 3·10^5). The string s contains only digits from 0 to 9.


-----Output-----

Print integer a — the number of substrings of the string s that are divisible by 4.

Note that the answer can be huge, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.


-----Examples-----
Input
124

Output
4

Input
04

Output
3

Input
5810438174

Output
9

Difficulty: interview

Starter code:

Solutions:
s = input()

ans = 0
for i in range(1, len(s)):
    if int(s[i - 1: i + 1]) % 4 == 0:
        ans += i
for x in s:
    if int(x) % 4 == 0:
        ans += 1

print(ans)


lst = input().strip()
s = []
for i in range(len(lst)):
    s.append(int(lst[i]))
answer = 0
for i in range(1, len(s)):
    if (s[i] + 10 * s[i - 1]) % 4 == 0:
        answer += i
for i in range(len(s)):
    if s[i] % 4 == 0:
        answer += 1
print(answer)


s = input()
n = len(s)
ans = 0
for i in range(1, n):
    if (int(s[i - 1]) * 10 + int(s[i])) % 4 == 0:
        ans += i
for i in range(n):
    if int(s[i]) % 4 == 0:
        ans += 1
print(ans)


s = input()
ans = 0
for i in range(len(s) - 1, -1, -1):
    if int(s[i - 1] + s[i]) % 4 == 0:
        ans += i
    if int(s[i]) % 4 == 0:
        ans += 1
print(ans)

s = [ord(c) - 48 for c in input()]
n = len(s)
ans = s.count(0) + s.count(4) + s.count(8)
for i in range(1, n):
    if (s[i-1]*10 + s[i]) % 4 == 0: ans += i
print(ans)


s = input()
cnt = 0
for i in range(1, len(s)):
    if int(s[i - 1] + s[i]) % 4 == 0:
        cnt += i
cnt += sum(int(i) % 4 == 0 for i in s)
print(cnt)


n=input()
ans=0
for i in range(len(n)-1):
    if int(n[i:i+2])%4==0:
        ans+=i+1
for i in n:
    if int(i)%4==0:
        ans+=1
print(ans)

s = input()
ans = 0
for i in s:
    if int(i) % 4 == 0:
        ans += 1
for i in range(len(s) - 1):
    if int(s[i:i + 2]) % 4 == 0:
        ans += i + 1
print(ans)


import math
from math import *
s = input()
ans = 0
c1 = 0
c2 = 0
for i in range(len(s)):
    c2 = int(s[i])
    if c2 % 4 == 0:
        ans += 1
        #++ans
    if i == 0:
        continue
    c1 = int(s[i-1])
    if (c1*10 + c2)%4 == 0:
        ans += i
print(ans)

def read():
  return [int(s) for s in input().split()]

s = input().strip()

res = 0

for i in range(len(s)):
  if int(s[i]) % 4 == 0:
    res += 1

for i in range(len(s)-1):
  if int(s[i:i+2]) % 4 == 0:
    res += (i + 1)

print(res)


string=input()
n=len(string)
ans=0
for i in range(n-1):
    if int(string[i])%4==0:
        ans+=1
    temp=string[i:i+2]
    if temp[0]=='0':
        temp=string[i+1]
    if(int(temp)%4==0):
        ans=ans+i+1

        
if(int(string[-1])%4==0):
    ans=ans+1
print(ans)


3

s = input()
# s = '124'
n = len(s)

ans = 0

for i in reversed(list(range(1, n))):
	if int(s[i])%2 == 0:
		if int(s[i-1:i+1])%4 == 0:
			ans += i
		if int(s[i])%4 == 0:
			ans += 1

if int(s[0])%4 == 0: ans += 1

print(ans)


#!/usr/bin/env python
s = list(map(int, list(input())))
a = 0
while len(s) > 0:
    if(not ((10 * s[len(s) - 2] + s[len(s) - 1]) % 4)):
        a += len(s) - 1
    if s[len(s) - 1] == 4 or s[len(s) - 1] == 8 or s[len(s) - 1] == 0:
        a += 1
    s.pop()
print(a)


s = input()
ans = 0
i = len(s) - 1
while(i != -1):
    if(i == 0):
        if(int(s[i]) % 4 == 0):
            ans+=1
    else:
        if(int(s[i-1]+s[i]) % 4 == 0):
            ans+=i
        if(int(s[i]) % 4 == 0): ans+=1
    i-=1
print(ans)
        


ch=input()
S=0
for i in range(len(ch)-1,-1,-1):
    if int(ch[i])%4==0:
        S=S+1
    ch1=ch[i-1]+ch[i]
    if int(ch1)%4==0:
        S=S+i
print(S)


s = input()
ans = 0
for i in range(0, len(s) - 1):
    if int(s[i:i + 2]) % 4 == 0:
        ans += i + 1
    if int(s[i]) % 4 == 0:
        ans += 1
if int(s[len(s) - 1]) % 4 == 0:
    ans += 1
print(ans)


s = input()
res = 0
for elem in s:
    if int(elem) % 4 == 0:
        res += 1
for i in range(len(s) - 1):
    if int(s[i:i + 2]) % 4 == 0:
        res += i + 1
print(res)

s = input()
res = 0
for elem in s:
    if int(elem) % 4 == 0:
        res += 1
for i in range(len(s) - 1):
    if int(s[i:i + 2]) % 4 == 0:
        res += i + 1
print(res)

def main():
    s = input()
    res = 0
    for elem in s:
        if int(elem) % 4 == 0:
            res += 1
    for i in range(len(s) - 1):
        if int(s[i:i + 2]) % 4 == 0:
            res += i + 1
    print(res)
    
main()

def main():
    s = input()
    res = 0
    for elem in s:
        if int(elem) % 4 == 0:
            res += 1
    for i in range(len(s) - 1):
        if int(s[i:i + 2]) % 4 == 0:
            res += i + 1
    print(res)
    
main()

from sys import stdin, stdout

def main():
    s = stdin.readline().rstrip()
    res = 0
    for elem in s:
        if int(elem) % 4 == 0:
            res += 1
    for i in range(len(s) - 1):
        if int(s[i:i + 2]) % 4 == 0:
            res += i + 1
    stdout.write(str(res))
    
main()

from sys import stdin, stdout

def main():
    s = stdin.readline().rstrip()
    res = 0
    for elem in s:
        if int(elem) % 4 == 0:
            res += 1
    for i in range(len(s) - 1):
        if int(s[i:i + 2]) % 4 == 0:
            res += i + 1
    stdout.write(str(res))
    
main()

s = input()
count=0
if int(s[0])%4==0:
	count+=1
for i in range(1,len(s)):
	if int(s[i-1])%2==0 and (s[i] in '048'):
		count+=(i+1)
	elif int(s[i-1])%2==1 and s[i] in '26':
		count+=i
	elif int(s[i])%4==0:
		count+=1
print(count)

s = [int(x) for x in input()]
ans = 0
if s[0] % 4 == 0:
    ans += 1
for i in range(1, len(s)):
    if s[i] % 4 == 0:
        ans += 1
    if (s[i] + 10 * s[i - 1]) % 4 == 0:
        ans += i
print(ans)

s=str(input())
count=0
if int(s[0])%4==0:
    count+=1
for i in range(1,len(s)):
    if int(s[i])%4==0:
        count+=1
    if int(s[i-1:i+1])%4==0:
        count+=1
        count+=i-1
print(count)