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

Source: codeforces | Difficulty: EASY
Tags: Dynamic programming


Solutions:
import sys
s = input()
n = len(s)
if n == 1:
	if int(s) % 4 == 0:
		print(1)
	else:
		print(0)
	sys.exit()
c = 0
for i in range(n - 1):
	l = int(s[i] + s[i + 1])
	if l % 4 == 0:
		c += i + 1
for i in range(n):
	l = int(s[i])
	if l % 4 == 0:
		c += 1
print(c)


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


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)


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


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


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


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


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())

def cd4(s):
	c = 0
	n = len(s)
	for i in range(n):
		if s[i] == '0' or s[i] == '4' or s[i] == '8':
			c += 1
	for i in range(n - 1):
		if (int(s[i]) * 10 + int(s[i + 1])) % 4 == 0:
			c += i + 1
	return c
s = input()
print(cd4(s))


s = input() + '1'
div4 = ['00', '04', '08', '12', '16', '20', '24', '28', '32', '36', '40', '44', '48', '52', '56', '60', '64', '68', '72', '76', '80', '84', '88', '92', '96']
div42 = ['0', '4', '8']
x = 0
for i in range(len(s)):
	if s[i:i + 2] in div4:
		x += i + 1
	if s[i] in div42:
		x += 1
print(x)


string = input()
resp = 0
if int(string[0]) % 4 == 0:
	resp += 1
for i in range(len(string) - 1):
	actual = int(string[i]) * 10 + int(string[i + 1])
	endingWithActual = i + 1
	if actual % 4 == 0:
		resp += endingWithActual
	if int(string[i + 1]) % 4 == 0:
		resp += 1
print(resp)


s = input()
n = len(s)
result = 0 + (int(s[-1]) % 4 == 0) + (int(s[0]) % 4 == 0) if len(s) > 1 else 0 + (int(s[-1]) % 4 == 0)
for i in range(n - 1, 0, -1):
	x = int(s[i - 1:i + 1])
	if x % 4 == 0:
		result += i
	if int(s[i]) % 4 == 0 and i < n - 1:
		result += 1
print(result)


import sys
(n, l, c, t) = (0, 0, -1, 0)
while True:
	l = c
	c = sys.stdin.read(1)
	if not c or c == '\n':
		break
	c = int(c)
	if c % 4 == 0:
		t += 1
	if l >= 0 and (l * 10 + c) % 4 == 0:
		t += n
	n += 1
print(t)


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


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()
s1 = list(s)
count = 0
count += s1.count('0')
count += s1.count('4')
count += s1.count('8')
for i in range(len(s) - 1):
	if int(''.join(s[i:i + 2])) % 4 == 0:
		count += i + 1
print(count)


possible = ['00', '04', '08'] + [str(4 * i) for i in range(3, 25)]
from sys import stdin
s = stdin.readline()
count = 0
for i in s:
	if i in ['0', '4', '8']:
		count += 1
for i in range(len(s) - 1):
	if s[i:i + 2] in possible:
		count += i + 1
print(count)


n = input()
A = list(n)
m = len(A)
c = 0
for i in A:
	if int(i) % 4 == 0:
		c = c + 1
for i in range(m - 1):
	if int(A[i] + A[i + 1]) % 4 == 0:
		c = c + (i + 1)
print(c)


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = 1
for k in range(t):
	s = input()
	n = len(s)
	(count, prev) = (0, 0)
	if int(s[0]) % 4 == 0:
		count += 1
	prev = int(s[0])
	for i in range(1, n):
		if int(s[i]) % 2 == 1:
			prev = int(s[i])
			continue
		if int(s[i]) % 4 == 0:
			if prev % 2 == 0:
				count += i + 1
			else:
				count += 1
		elif (int(s[i]) + 10 * prev) % 4 == 0:
			count += i
		prev = int(s[i])
	print(count)


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


a = input().strip()
n = len(a)
count = 0
for i in range(n):
	if int(a[i]) % 4 == 0:
		count += 1
	if i + 1 < n and int(a[i:i + 2]) % 4 == 0:
		count += i + 1
print(count)


import math
import collections
import bisect

def arrPrint(a):
	return ' '.join([str(i) for i in a])

def gridPrint(a):
	return '\n'.join([' '.join([str(j) for j in a[i]]) for i in range(len(a))])

def isPalindrome(s):
	for i in range(len(s) // 2):
		if not s[i] == s[-i - 1]:
			return False
	return True

def primeCheck(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

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


s = input()
(n1, n2, n4, c4) = (0, 0, 0, 0)
for i in range(len(s)):
	r = int(s[i]) % 4
	if r == 1 or r == 3:
		(n1, n2, n4) = (i + 1, 0, 0)
	elif r == 2:
		(n1, n2, n4) = (0, n2 + n4 + 1, n1)
	else:
		(n1, n2, n4) = (0, n1, n2 + n4 + 1)
	c4 += n4
print(c4)


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


n = input().strip()
D = [0] * len(n)
if len(n) >= 2:
	if int(n[0]) % 4 == 0:
		D[0] += 1
	if int(n[1]) % 4 == 0:
		D[1] += 1
	if int(n[0:2]) % 4 == 0:
		D[1] += 1
	D[1] += D[0]
	for i in range(2, len(n)):
		D[i] = D[i - 1]
		if int(n[i]) % 4 == 0:
			D[i] += 1
		if int(n[i - 1:i + 1]) % 4 == 0:
			D[i] += i
elif int(n) % 4 == 0:
	D[0] += 1
print(D[-1])


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


n_str = input()
count = 0
total = 0

def is_div(num):
	return int(num) % 4 == 0
for j in n_str:
	if is_div(j):
		total += 1
for i in range(0, len(n_str) - 1):
	if is_div(n_str[i:i + 2]):
		total += i + 1
print(total)


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


import sys
input = sys.stdin.readline
a = ord('a')
s = input().strip()
n = len(s)
ans = 0
for i in range(n - 1, -1, -1):
	if int(s[i]) % 4 == 0:
		ans += 1
	if i - 1 >= 0 and int(s[i - 1:i + 1]) % 4 == 0:
		ans += i
print(ans)


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


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


s = input()
n = len(s)
digits = list(s)
cnt = 0
for i in range(n):
	num1 = int(digits[i])
	if num1 % 4 == 0:
		cnt += 1
	if i > 0:
		num2 = int(digits[i]) + int(digits[i - 1]) * 10
		if num2 % 4 == 0:
			cnt += i
print(cnt)


s = input()
y = []
for i in s:
	y.append(i)
count = 0
for i in y:
	if int(i) % 4 == 0:
		count += 1
i = 1
while i < len(s):
	if int(s[i - 1:i + 1]) % 4 == 0:
		count += i
	i += 1
print(count)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		l = list(input())
		n = len(l)
		ans = 0
		if int(l[0]) % 4 == 0:
			ans += 1
		for i in range(1, n):
			if int(l[i]) % 4 == 0:
				ans += 1
			if (int(l[i - 1]) * 10 + int(l[i])) % 4 == 0:
				ans += i
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


s = input()
a = [0]
count = 0
ans = 0
for i in range(1, len(s)):
	p = int(s[i - 1] + s[i])
	if p % 4 == 0:
		a.append(1)
	else:
		a.append(0)
for i in range(len(a)):
	if a[i] == 1:
		count = count + i
for i in s:
	if int(i) % 4 == 0:
		ans += 1
output = count + ans
print(output)


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
s = inp()
ans = int(s[0] in '048')
for i in range(1, len(s)):
	if s[i] in '048':
		ans += 1
	if int(s[i - 1:i + 1]) % 4 == 0:
		ans += i
print(ans)


s = input()
res = 0
t = s[0]
n = len(s)
if int(s[0]) % 4 == 0:
	res = 1
for i in range(1, n):
	t += s[i]
	if int(s[i]) % 4 == 0:
		res += 1
	q = int(t)
	if q % 4 == 0:
		res += i
	t = t[1:]
print(res)


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 = input()
c = 0
i = len(s)
for a in s:
	if int(a) % 4 == 0:
		c += 1
while i > 1:
	if int(s[i - 2:i]) % 4 == 0:
		c += i - 1
	i -= 1
print(c)


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


s = input()
t = 0
for x in range(len(s) - 1):
	n = int(s[x] + s[x + 1])
	if n % 4 == 0:
		t += x + 1
	if int(s[x]) % 4 == 0:
		t += 1
if int(s[-1]) % 4 == 0:
	t += 1
print(t)


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


seq = list(map(int, list(input())))
n = len(seq)
ans = 0
for i in range(n - 1, -1, -1):
	s = seq[i]
	if s % 4 == 0:
		ans += 1
		if i > 0 and seq[i - 1] % 2 == 0:
			ans += i
	elif s % 4 == 2:
		if i > 0 and seq[i - 1] % 2 == 1:
			ans += i
print(ans)


s = input()
l = list(map(int, list(s)))
c = 0

def work():
	global c, l
	for i in range(len(l) - 1, -1, -1):
		if i == 0:
			c += int(l[0] % 4 == 0)
		elif i > 0 and (l[i - 1] * 10 + l[i]) % 4 == 0:
			c += i + int(l[i] % 4 == 0)
		elif l[i] % 4 == 0:
			c += 1
work()
print(c)


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


s = input()
n = len(s)
i = n - 1
ans = 0
while i > 0:
	number = int(s[i - 1] + s[i])
	if s[i] == '4' or s[i] == '8' or s[i] == '0':
		ans += 1
	if number % 4 == 0:
		ans += i
	i -= 1
if s[0] == '4' or s[0] == '8' or s[0] == '0':
	ans += 1
print(ans)


import sys
input = sys.stdin.readline
n = input().strip()
l = len(n)
counter = 0
for i in n:
	if int(i) % 4 == 0:
		counter += 1
for i in range(1, l):
	if int(n[i - 1] + n[i]) % 4 == 0:
		counter += i
print(counter)


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
	if i == 0:
		continue
	c1 = int(s[i - 1])
	if (c1 * 10 + c2) % 4 == 0:
		ans += i
print(ans)


import math
import bisect
import sys
from collections import OrderedDict
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
S = insr()
out = 0
for i in range(len(S) - 1):
	if int(S[i]) % 4 == 0:
		out += 1
	if int(S[i] + S[i + 1]) % 4 == 0:
		out += i + 1
if int(S[-1]) % 4 == 0:
	out += 1
print(out)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
s = input()
ans = 0
for (i, ch) in enumerate(s):
	if ch == '0' or ch == '4' or ch == '8':
		ans += 1
	if i > 0:
		if int(s[i - 1] + s[i]) % 4 == 0:
			ans += i
print(ans)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
j = None
r = 0
p = 0
for i in minp():
	r += int(i) % 4 == 0
	if j != None:
		if int(j + i) % 4 == 0:
			r += p
	p += 1
	j = i
print(r)


s = input()
a = s.count('0') + s.count('4') + s.count('8')
for i in range(len(s) - 1):
	if int(s[i:i + 2]) % 4 == 0:
		a += i + 1
print(a)


s = input()
ans = 0
a = [0, 0, 0, 0]
new_a = [0, 0, 0, 0]
for c in s:
	d = int(c) % 4
	for i in range(4):
		new_a[i] = 0
	new_a[d] = 1
	for i in range(4):
		new_a[(2 * i + d) % 4] += a[i]
	(a, new_a) = (new_a, a)
	ans += a[0]
print(ans)


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


def build_lps_table(s):
	table = [0] * len(s)
	index = 0
	for i in range(1, len(s)):
		if s[i] == s[index]:
			table[i] = index + 1
			index += 1
		else:
			index = table[i - 1]
			while index > 0 and s[index] != s[i]:
				index = table[index - 1]
			if s[i] == s[index]:
				index += 1
			table[i] = index
	return table

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


l = list(input())
temp = []
count = 0
for i in range(len(l) - 1):
	x = int(l[i] + l[i + 1])
	y = int(l[i])
	if x % 4 == 0:
		temp.append(i + 1)
	if y % 4 == 0:
		count += 1
if int(l[len(l) - 1]) % 4 == 0:
	count += 1
xs = 0
for i in range(len(temp)):
	xs += temp[i]
print(count + xs)


n = input()
count = [n.count('4'), n.count('0'), n.count('8')]
ans = sum(count)
for i in range(1, len(n)):
	if int(n[i - 1] + n[i]) % 4 == 0:
		ans = ans + i
print(ans)


from sys import stdin
s = stdin.readline().rstrip('\n')
ans = 0
n = len(s)
for i in range(1, n):
	if int(s[i - 1:i + 1]) % 4 == 0:
		ans += i
ans += s.count('0') + s.count('4') + s.count('8')
print(ans)


import sys
s = input()
n = 0
for i in range(len(s) - 1):
	if (int(s[i]) / 4).is_integer():
		n += 1
	if (int(s[i] + s[i + 1]) / 4).is_integer():
		n += i + 1
if (int(s[-1]) / 4).is_integer():
	n += 1
print(n)


S = input()
L = len(S)
res = 0
for i in range(L)[::-1]:
	if int(S[i]) % 4 == 0:
		res += 1
	if i != 0 and int(S[i - 1:i + 1]) % 4 == 0:
		res += i
print(res)


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)


s = input()
n = len(s)
t = 0
for i in s:
	if i == '4' or i == '8' or i == '0':
		t += 1
for i in range(n - 1):
	x = s[i:i + 2]
	if int(x) % 4 == 0:
		t += i + 1
print(t)


n = input()
n += '~'
c = 0
if int(n[0]) % 4 == 0:
	c += 1
for i in range(1, len(n) - 1):
	if int(n[i]) % 4 == 0:
		c += 1
	if int(n[i - 1:i + 1]) % 4 == 0:
		c += i
print(c)


from sys import stdin, stdout
input = stdin.readline
s = list(input())
ans = 0
s.pop()
n = len(s)
if int(s[0]) % 4 == 0:
	ans += 1
for i in range(1, n):
	if int(s[i]) % 4 == 0:
		ans += 1
	if int(''.join(s[i - 1:i + 1])) % 4 == 0:
		ans += i
print(ans)


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


longArray = input()
(a, b, c) = (longArray.count('0'), longArray.count('4'), longArray.count('8'))
(count, size) = (a + b + c, len(longArray))
for x in range(size - 2, -1, -1):
	h = int(longArray[x:x + 2])
	if not h % 4:
		count += size - (size - x) + 1
print(count)


count = 0
x = input()
for i in range(len(x) - 1):
	z = x[i:i + 2]
	if int(z) % 4 == 0:
		count += i + 1
for j in range(len(x)):
	if x[j] in ['0', '4', '8']:
		count += 1
print(count)


s = input()
p = 0
a = [0, 4, 8]
b = [2, 6]
if int(s[0]) in a:
	p += 1
for i in range(1, len(s)):
	if int(s[i]) in a:
		if int(s[i - 1]) % 2 == 0:
			p += i + 1
		else:
			p += 1
	elif int(s[i]) in b:
		if int(s[i - 1]) % 2:
			p += i
print(p)


a = input()
count = 0
dividable_2chunks = 0
i = len(a) - 1
while i >= 0:
	count += dividable_2chunks
	if a[i] in ('0', '4', '8'):
		count += 1
	if i < len(a) - 1 and int(a[i:i + 2]) % 4 == 0:
		count += 1
		dividable_2chunks += 1
	i -= 1
print(count)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
s = input()
n = len(s)
ans = 0
for i in range(n):
	num = int(s[i])
	ans += num % 4 == 0
	if i > 0:
		num = int(s[i - 1]) * 10 + num
		if num % 4 == 0:
			ans += i
print(ans)


def solution():
	o = ord
	s = [o(x) - 48 for x in input()]
	l_s = len(s)
	count = 1 if not s[0] % 4 else 0
	for i in range(1, l_s):
		t = 0
		a = s[i]
		b = s[i - 1]
		if not a % 4:
			t += 1
		t1 = a + 10 * b
		if not t1 % 4:
			t += i
		count += t
	print(count)
solution()


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


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


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


import sys
import os
import math
import copy
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations, accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def watch(x):
	return print(x)

def common(l1, l2):
	return set(l1).intersection(l2)

def Most_frequent(list):
	return max(set(list), key=list.count)

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


num = input()
i = 0
counter = 0
max = len(num)
for i in range(max):
	if int(num[i:i + 1]) % 4 == 0:
		counter += 1
	if int(num[i:i + 2]) % 4 == 0 and i + 2 <= max:
		counter += i + 1
print(counter)


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


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


(s, r) = (input(), 0)
for i in range(len(s) - 1):
	a = s[i] + s[i + 1]
	if int(a) % 4 == 0:
		r += i + 1
	if s[i] in ['0', '4', '8']:
		r += 1
print(r + 1 if s[-1] in ['0', '4', '8'] else r)


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
string = input()
l = len(string)
ans = 0
for i in string:
	if i == '0' or i == '4' or i == '8':
		ans += 1
for i in range(l - 1):
	if int(string[i] + string[i + 1]) % 4 == 0:
		ans += i + 1
print(ans)


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


s = input().rstrip()
x = list(s)
G = 0
for i in range(0, len(x)):
	if i == 0:
		if int(x[i]) % 4 == 0:
			G += 1
	else:
		f = x[i]
		if int(f) % 4 == 0:
			G += 1
		g = x[i - 1]
		c = g + f
		D = int(c)
		if D % 4 == 0:
			G += i
print(G)


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		s = R()
		l = len(s) - 1
		total = 0
		for i in range(l):
			total += not int(s[i]) % 4
		for i in range(1, l):
			total += i if not int(s[i - 1] + s[i]) % 4 else 0
		W('%d\n' % total)
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


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


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
for i in s:
	if i == '0' or i == '4' or i == '8':
		ans += 1
for i in range(len(s) - 1):
	x = int(s[i] + s[i + 1])
	if x % 4 == 0:
		ans += i + 1
print(ans)


a = input()
a = list(a)
ans = 0
for i in a:
	if int(i) % 4 == 0:
		ans += 1
while len(a) >= 2:
	if int(''.join(a[-2:])) % 4 == 0:
		ans += len(a) - 1
	a.pop()
print(ans)


def countDivisbleby4(s):
	n = len(s)
	count = 0
	for i in range(0, n, 1):
		if s[i] == '4' or s[i] == '8' or s[i] == '0':
			count += 1
	for i in range(0, n - 1, 1):
		h = (ord(s[i]) - ord('0')) * 10 + (ord(s[i + 1]) - ord('0'))
		if h % 4 == 0:
			count = count + i + 1
	return count
s = input()
a = []
for i in range(0, len(s)):
	a.append(s[i])
print(countDivisbleby4(a))


s = input()
count = 0
count += sum((1 for c in s if int(c) % 4 == 0))
for pos in range(len(s) - 1):
	start = pos
	end = pos + 2
	if int(s[start:end]) % 4 == 0:
		count += 1
		count += start
print(count)


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


l = [char for char in input()]
n = len(l)
count = 0
for x in l:
	if int(x) % 4 == 0:
		count += 1
for i in range(n - 1, 0, -1):
	if int(l[i - 1] + l[i]) % 4 == 0:
		count += i
print(count)


s = input()
ans = 0
prev = -1
for (i, char) in enumerate(s):
	nb = int(char)
	if nb % 4 == 0:
		ans += 1
	if i and (prev * 10 + nb) % 4 == 0:
		ans += i
	prev = nb
print(ans)


import sys
input = sys.stdin.readline
s = input().strip()
count = 0
for i in range(len(s)):
	if s[i] in ['0', '4', '8']:
		count += 1
for i in range(len(s) - 1):
	x = s[i:i + 2]
	if int(x) % 4 == 0:
		count += i + 1
sys.stdout.write('%d' % count)


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


answer = 0
s = list(map(int, list(input())))
for num in s:
	if num % 4 == 0:
		answer += 1
i = 1
while i < len(s):
	if (s[i] + s[i - 1] * 2) % 4 == 0:
		answer += i
	i += 1
print(answer)


def do_1():
	(n, b, p) = map(lambda x: int(x), input().split(' '))
	print((2 * b + 1) * (n - 1), p * n)

def do_2():
	s = input()
	counter = 0
	if int(s[0]) % 4 == 0:
		counter = 1
	if len(s) <= 1:
		print(counter)
		return
	if int(s[1]) % 4 == 0:
		counter += 1
	if int(s[0:2]) % 4 == 0:
		counter += 1
	for i in range(2, len(s)):
		current = int(s[i])
		if current % 4 == 0:
			counter += 1
		current = int(s[i - 1:i + 1])
		if current % 4 == 0:
			counter += i
	print(counter)
	return
do_2()


string = input()
prev = str(5)
ans = 0
for i in range(len(string) - 1, -1, -1):
	num = int(string[i])
	if num % 4 == 0:
		ans += 1
	last2 = int(string[i] + prev)
	if last2 % 4 == 0:
		ans += i + 1
	prev = string[i]
print(ans)


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


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


class CodeforcesTask628BSolution:

	def __init__(self):
		self.result = ''
		self.number = ''

	def read_input(self):
		self.number = input()

	def process_task(self):
		next_nums = [[str(y) + str(x) for y in range(10) if not int(str(y) + str(x)) % 4] for x in range(10) if not x % 2]
		result = 0
		ends = []
		for n in next_nums:
			ends += n
		ends.sort()
		for x in range(len(self.number) - 1):
			if self.number[x:x + 2] in ends:
				result += x + 1
		result += self.number.count('0')
		result += self.number.count('4')
		result += self.number.count('8')
		self.result = str(result)

	def get_result(self):
		return self.result
Solution = CodeforcesTask628BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import sys
s = sys.stdin.readline()[:-1]
k = 0
for x in s:
	if int(x) % 4 == 0:
		k += 1
for i in range(1, len(s)):
	if int(s[i - 1] + s[i]) % 4 == 0:
		k += i
print(k)


string = input()
cont = 0
for i in range(len(string) - 1):
	div_4 = int(string[i])
	if div_4 % 4 == 0:
		cont += 1
	aux = ''
	vetor = [string[i], string[i + 1]]
	aux = aux + vetor[0]
	aux = aux + vetor[1]
	div_4_aux = int(aux)
	if div_4_aux % 4 == 0:
		cont = cont + i + 1
div_4 = int(string[-1])
if div_4 % 4 == 0:
	cont += 1
print(cont)


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 func(s, n):
	count = 0
	for i in range(n - 1):
		if int(s[i]) % 4 == 0:
			count += 1
		string = s[i] + s[i + 1]
		if int(string) % 4 == 0:
			count += i + 1
	if int(s[n - 1]) % 4 == 0:
		count += 1
	return count
s = input()
n = len(s)
count = func(s, n)
print(count)


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


def main():
	l = [ord(c) - 48 for c in input()]
	(y, res) = (1, l.count(0) + l.count(4) + l.count(8))
	for i in range(len(l) - 1, -1, -1):
		x = l[i]
		if not (x * 10 + y) % 4:
			res += i + 1
		y = x
	print(res)
main()


s = input()
n = len(s)
D = set()
for i in range(100):
	if i % 4 == 0:
		x = str(i)
		if i < 10:
			x = '0' + x
		D.add(x)
c = 0
for i in range(n - 1):
	if s[i] + s[i + 1] in D:
		c = c + i + 1
for i in range(n):
	if int(s[i]) % 4 == 0:
		c = c + 1
print(c)


number = input()
i = 0
len_number = len(number)
count = 0
control = 0
while i < len_number:
	j = i
	test_number = number[j:i + 1]
	if int(test_number) % 4 == 0:
		count += 1
	if j != 0 and int(number[j - 1:i + 1]) % 4 == 0:
		count += j
	j -= 1
	i += 1
print(count)


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


number = input()
count = number.count('0') + number.count('4') + number.count('8')
for i in range(1, len(number)):
	n = number[i - 1:i + 1]
	if int(n) % 4 == 0:
		count += i
print(count)


l = input()
n = len(l)
coun = 0
for i in range(0, n - 1):
	if int(l[i] + l[i + 1]) % 4 == 0:
		coun += i + 1
	if l[i] == '0' or l[i] == '4' or l[i] == '8':
		coun += 1
if l[n - 1] == '0' or l[n - 1] == '4' or l[n - 1] == '8':
	coun += 1
print(coun)


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


def main():
	n = input()
	l = len(n)
	ans = 0
	for i in range(l):
		if n[i] in ['0', '4', '8']:
			ans += 1
	for i in range(l - 1):
		if int(n[i] + n[i + 1]) % 4 == 0:
			ans += i + 1
	print(ans)
main()


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)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip('\n')
s = input()
n = len(s)
ans = 0
ans += s.count('4')
ans += s.count('8')
ans += s.count('0')
for i in range(1, n):
	k = s[i - 1] + s[i]
	if int(k) % 4 == 0:
		ans += i
print(ans)


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


import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
n -= 1
for j in range(n):
	p = s[j]
	if int(p) % 4 == 0:
		ans += 1
	if j >= 1:
		if int(s[j - 1] + s[j]) % 4 == 0:
			ans += j
print(ans)


import sys
from collections import *
import os.path
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	s = st()
	ans = 0
	n = len(s)
	for i in range(n):
		if int(s[i]) % 4 == 0:
			ans += 1
		if i + 1 < n:
			a = int(s[i] + s[i + 1])
			if a % 4 == 0:
				ans += i + 1
	pr(ans)
solve()


import sys
input = sys.stdin.readline
s = input()
ans = 0
for i in s:
	if i in '048':
		ans += 1
n = len(s) - 1
for i in range(n - 1):
	x = int(s[i]) * 10 + int(s[i + 1])
	if x % 4 == 0:
		ans += i + 1
print(ans)


from sys import stdin, stdout
import sys, os
s = stdin.buffer.readline().decode('ascii').rstrip('\n\r')
count = 0
for i in s:
	if int(i) % 4 == 0:
		count += 1
for i in range(1, len(s)):
	if int(s[i - 1] + s[i]) % 4 == 0:
		count += i
print(count)


from sys import stdin
input = lambda : stdin.readline()
from math import ceil, sqrt, gcd
s = list(map(int, list(input().strip())))
su = s.count(0) + s.count(4) + s.count(8)
for i in range(len(s) - 1, 0, -1):
	if (10 * s[i - 1] + s[i]) % 4 == 0:
		su += i
print(su)


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


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


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


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


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


3
s = input()
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)


arr = list(map(int, list(input())))
ans = 0
for i in range(len(arr)):
	if arr[i] == 8 or arr[i] == 4 or arr[i] == 0:
		ans += 1
for i in range(len(arr) - 1):
	if (arr[i] * 10 + arr[i + 1]) % 4 == 0:
		ans += i + 1
print(ans)


(s, k) = (input(), 0)
for i in range(1, len(s)):
	if int(s[i - 1] + s[i]) % 4 == 0:
		k += i
print(k + sum((s.count(d) for d in '048')))


from collections import defaultdict
s = input()
valid = defaultdict(lambda : False)
valid['00'] = True
valid['04'] = True
valid['08'] = True
for i in range(12, 101, 4):
	valid[str(i)] = True
ans = 0
for i in range(0, len(s) - 1):
	temp = s[i] + s[i + 1]
	if valid[temp] == True:
		ans += i + 1
	if s[i] == '4':
		ans += 1
	elif s[i] == '8':
		ans += 1
	elif s[i] == '0':
		ans += 1
if s[len(s) - 1] == '4':
	ans += 1
elif s[len(s) - 1] == '8':
	ans += 1
elif s[len(s) - 1] == '0':
	ans += 1
print(ans)


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


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
s = [int(i) for i in S()]
ans = 1 if s[0] % 4 == 0 else 0
p = 1
x = s[0] * 10
for i in s[1:]:
	if i % 4 == 0:
		ans += 1
	x += i
	if x % 4 == 0:
		ans += p
	x = i * 10
	p += 1
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
s = input()
n = len(s)
a = list()
ct = 0
for i in s:
	a.append(int(i))
	if a[-1] % 4 == 0:
		ct += 1
for i in range(1, n):
	if (a[i - 1] * 10 + a[i]) % 4 == 0:
		ct += i
print(ct)


st = input()
l = len(st)
c = 0
for i in range(l - 2, -1, -1):
	m = int(st[i])
	n = int(st[i + 1])
	k = m * 10 + n
	if k % 4 == 0:
		c = c + i + 1
for j in range(0, l):
	a = int(st[j])
	if a % 4 == 0:
		c = c + 1
print(c)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	l = list(input())
	n = len(l)
	ans = 0
	if int(l[0]) % 4 == 0:
		ans += 1
	for i in range(1, n):
		if int(l[i]) % 4 == 0:
			ans += 1
		if (int(l[i - 1]) * 10 + int(l[i])) % 4 == 0:
			ans += i
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)

def hnbhai():
	s = list(sa())
	tot = 0 if int(s[0]) % 4 != 0 else 1
	for i in range(1, len(s)):
		if int(s[i - 1] + s[i]) % 4 == 0:
			tot += i
		if int(s[i]) % 4 == 0:
			tot += 1
	print(tot)
for _ in range(1):
	hnbhai()


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


import sys
import math
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def solve(s):
	ret = 0
	N = len(s)
	for i in range(N):
		d = int(s[i])
		if d % 4 == 0:
			ret = ret + 1
		if i >= 1:
			p = int(s[i - 1])
			if (p * 10 + d) % 4 == 0:
				ret = ret + i
	print(ret)
s = inStr()
solve(s)


s = list(map(int, list(input())))
count = 0
for i in range(len(s)):
	if s[i] % 4 == 0:
		count += 1
	if i > 0:
		num = 10 * s[i - 1] + s[i]
		if num % 4 == 0:
			count += i
print(count)


s = str(input())
ans = 0
if s[0] in '048':
	ans += 1
if len(s) > 1:
	for k in range(1, len(s)):
		if s[k] in '048':
			ans += 1
		if int(s[k - 1:k + 1]) % 4 == 0:
			ans += k
print(ans)


s = input()
n = len(s)
suma = 0
for i in range(n - 1, 0, -1):
	p1 = s[i]
	p2 = s[i - 1]
	st = ''
	st += s[i - 1] + s[i]
	st = int(st)
	if int(s[i]) % 4 == 0:
		suma += 1
	if st % 4 == 0:
		suma += 1
		suma += i - 1
if int(s[0]) % 4 == 0:
	suma += 1
print(suma)


s = list(input())
d = 0
for i in range(len(s)):
	if i != 0:
		num = int(s[i - 1]) * 10 + int(s[i])
		if num % 4 == 0:
			d += i
	if int(s[i]) % 4 == 0:
		d += 1
print(d)


import math
str_in = ''
str_in = input()
count = 0
len_s = len(str_in)
i = len_s - 1
curr_i = len_s
while i >= 0:
	if curr_i - i == 2:
		if int(str_in[i:curr_i]) % 4 == 0:
			count = count + 1 + i
		curr_i = i + 1
	else:
		if int(str_in[i:curr_i]) % 4 == 0:
			count = count + 1
		i = i - 1
print(count)


import sys
input = sys.stdin.readline
s = input().strip()
ans = 0
for i in range(len(s)):
	if int(s[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)


from sys import stdin, stdout

def main():
	s = stdin.readline().rstrip()
	count = 0
	for (i, e) in enumerate(s):
		if int(e) % 4 == 0:
			count += 1
		if i >= 1:
			if int(s[i - 1:i + 1]) % 4 == 0:
				count += i
	stdout.write(f'{count}\n')
main()


l = list(map(int, input()))
c = 0
n = len(l)
for i in range(n - 1):
	if l[i] % 4 == 0:
		c += 1
	if l[i] % 2 == 0 and l[i + 1] in [0, 4, 8] or (l[i] % 2 != 0 and l[i + 1] in [2, 6]):
		c += i + 1
if l[n - 1] % 4 == 0:
	c += 1
print(c)


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


s = list(map(int, list(input())))
l = [0] * len(s)
if s[0] % 4 == 0:
	l[0] = 1
for i in range(1, len(s)):
	if s[i] % 4 == 0:
		l[i] += 1
		if s[i - 1] % 2 == 0:
			l[i] += i
	elif s[i] % 2 == 0 and s[i] % 4 != 0 and (s[i - 1] % 2 == 1):
		l[i] += i
	l[i] += l[i - 1]
print(l[-1])


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


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


s = input()
dp = []
dp.append(0)
for i in range(len(s)):
	if int(s[i]) % 4 == 0:
		dp.append(dp[i] + 1)
	else:
		dp.append(dp[i])
	if i > 0 and int(s[i - 1] + s[i]) % 4 == 0:
		dp[i + 1] = dp[i + 1] + i
print(dp[len(s)])


import sys
input = sys.stdin.readline
num = input().strip()
subs = 0
x = len(num)
for i in range(x - 1):
	if int(num[x - 1 - i]) % 4 == 0:
		subs += 1
	if int(num[x - 2 - i:x - i]) % 4 == 0:
		subs += x - 1 - i
if int(num[0]) % 4 == 0:
	subs += 1
print(subs)


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


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


k = input()
s = 0 + (int(k[0]) % 4 == 0)
for (i, j) in enumerate(k[1:]):
	if int(j) % 4 == 0:
		s += 1
	if int(k[i] + j) % 4 == 0:
		s += i + 1
print(s)


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


import sys
from itertools import permutations, combinations
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

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


s = input()
r = 0
for (i, c) in enumerate(s):
	if int(c) % 4 == 0:
		r += 1
	if i == 0:
		continue
	if int(s[i - 1:i + 1]) % 4 == 0:
		r += i
print(r)


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


def main():
	a = input()
	a = list(a)
	summ = 0
	for i in range(len(a)):
		if int(a[i]) % 4 == 0:
			summ += 1
		if i != 0 and int(''.join((k for k in a[i - 1:i + 1]))) % 4 == 0:
			summ += i
	return summ
print(main())


n = input()
s = 0
l = []
for i in n:
	l.append(int(i))
for i in l:
	if int(i) % 4 == 0:
		s = s + 1
cur = 0
for i in range(len(l) - 1):
	s1 = 10 * l[i] + l[i + 1]
	if s1 % 4 == 0:
		s = s + (i + 1)
print(s)


q = input()
t = q.count('0') + q.count('4') + q.count('8')
w = len(q)
for i in range(w - 1):
	if int(q[w - i - 2] + q[w - i - 1]) % 4 == 0:
		t += w - i - 1
print(t)


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


def solution():
	s = input()
	l_s = len(s)
	count = 1 if not int(s[0]) % 4 else 0
	for i in range(1, l_s):
		t = 0
		a = int(s[i])
		b = int(s[i - 1])
		if not a % 4:
			t += 1
		t1 = a + 10 * b
		if not t1 % 4:
			t += 1 + (i - 1)
		count += t
	print(count)
solution()


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


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
s = input()
n = len(s)
ans = 0
if int(s[0]) % 4 == 0:
	ans += 1
for i in range(1, n):
	if int(s[i - 1] + s[i]) % 4 == 0:
		ans += i
	if int(s[i]) % 4 == 0:
		ans += 1
print(ans)


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


R = lambda : map(int, input().split())
s = input()
cnt = 1 if int(s[-1]) % 4 == 0 else 0
for i in range(len(s) - 2, -1, -1):
	if int(s[i]) % 4 == 0:
		cnt += 1
	if (10 * int(s[i]) + int(s[i + 1])) % 4 == 0:
		cnt += i + 1
print(cnt)


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def printlist(l):
	print(' '.join([str(x) for x in l]))
s = ip()
n = len(s)
a = [int(s[i]) % 2 == 0 for i in range(n)]
if len(s) == 1:
	if int(s[0]) % 4 == 0:
		print(1)
	else:
		print(0)
	exit()
sum = int(s[0]) % 4 == 0
for i in range(1, n):
	sum += (int(s[i]) % 4 == 2) * (1 - a[i - 1]) * i + (int(s[i]) % 4 == 0) * a[i - 1] * i + (int(s[i]) % 4 == 0)
print(sum)


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)


A = input()
result = 0
for i in range(len(A) - 1):
	tmp = int(A[i] + A[i + 1])
	if tmp % 4 == 0:
		result += i + 1
for i in range(len(A)):
	if int(A[i]) % 4 == 0:
		result += 1
print(result)


s = input()
r = 0
for i in range(len(s)):
	if int(s[i]) & 3 == 0:
		r += 1
	if i > 0 and int(s[i - 1:i + 1]) & 3 == 0:
		r += i
print(r)


def divv(ag):
	ag = int(ag)
	if ag % 4 == 0:
		return 1
	else:
		return 0
s = str(input())
cnt = 0
for i in range(0, len(s)):
	ag = s[i]
	ag = int(ag)
	if ag % 4 == 0:
		cnt = cnt + 1
i = 0
for i in range(len(s) - 2, -1, -1):
	ag = s[i:i + 2]
	if divv(ag) == 1:
		cnt = cnt + 1
		cnt = cnt + i
print(cnt)


p = input()
count = 0
for i in range(len(p)):
	if int(p[i]) % 4 == 0:
		count += 1
	if i >= 1 and int(p[i - 1:i + 1]) % 4 == 0:
		count += i
print(count)


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)


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()
tot = 0
for i in range(len(s)):
	if int(s[i]) % 4 == 0:
		tot += 1
	if i != len(s) - 1 and int(s[i:i + 2]) % 4 == 0:
		tot += i + 1
print(tot)


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


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


def solve(num):
	res = 0
	l = len(num)
	for n in num:
		if int(n) % 4 == 0:
			res += 1
	for i in range(l - 1):
		l2 = num[i] + num[i + 1]
		if int(l2) % 4 == 0:
			res += i + 1
	return res
num = input()
print(solve(num))


from math import *
s = input()
n = len(s)
ans = o = e = 0
for i in range(n):
	if s[i] == '4' or s[i] == '8' or s[i] == '0':
		ans += 1
		if i > 0 and int(s[i - 1]) % 2 == 0:
			ans += i
	elif s[i] == '2' or s[i] == '6':
		if i > 0 and int(s[i - 1]) % 2 == 1:
			ans += i
print(ans)


def solution(s):
	ret = 1 if int(s[0]) % 4 == 0 else 0
	for i in range(1, len(s)):
		if (int(s[i - 1]) * 10 + int(s[i])) % 4 == 0:
			ret += i
		if int(s[i]) % 4 == 0:
			ret += 1
	return ret
print(solution(input()))


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)


s = input()
n = 0
if int(s[0]) % 4 is 0:
	n += 1
for (i, c) in enumerate(s[1:]):
	ch = s[i] + c
	if int(c) % 4 is 0:
		n += 1
	if int(ch) % 4 is 0:
		n += i + 1
print(n)


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


s = input()
n = len(s)
t = 0
if s[0] == '0' or s[0] == '4' or s[0] == '8':
	t += 1
for x in range(1, n):
	if s[x] == '0' or s[x] == '4' or s[x] == '8':
		t += 1
	m = (ord(s[x - 1]) - 48) * 10 + ord(s[x]) - 48
	if m % 4 == 0:
		t += x
print(t)


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


s = input()
c = 0
for i in s:
	if int(i) % 4 == 0:
		c += 1
(i, j) = (len(s) - 1, len(s) - 2)
while j >= 0:
	if int(''.join(s[j:i + 1])) % 4 == 0:
		c += len(s) - (len(s) - j) + 1
	i -= 1
	j -= 1
print(c)


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


st = input()
l = len(st)
s = [int(st[i]) for i in range(l)]
count = 0
for i in s:
	if i == 0 or i == 4 or i == 8:
		count += 1
if l == 1:
	print(count)
	exit(0)
for i in range(l - 1):
	num = s[i] * 10 + s[i + 1]
	if num % 4 == 0:
		count += i + 1
print(count)


import sys
s = sys.stdin.buffer.readline().decode('utf-8').rstrip()
dp = [0] * 4
ans = 0
for d in map(int, s):
	m = d % 4
	ndp = [0] * 4
	ndp[m] += 1
	for x in range(4):
		ndp[(x * 10 + m) % 4] += dp[x]
	dp = ndp
	ans += dp[0]
print(ans)


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


S = input()
result = 0
for i in range(len(S)):
	if i == 0:
		if int(S[i]) % 4 == 0:
			result += 1
	elif int(S[i]) % 4 == 0:
		if int(S[i - 1:i + 1]) % 4 == 0:
			result += i + 1
		else:
			result += 1
	elif int(S[i - 1:i + 1]) % 4 == 0:
		result += i
print(result)


def div4(s):
	return int(s[-2:]) % 4 == 0
n = input()
total = 0
for c in n:
	if int(c) % 4 == 0:
		total += 1
for i in range(1, len(n)):
	d2 = n[i - 1:i + 1]
	if div4(d2):
		total += i
print(total)


st = str(input())
n = len(st)
array = [0 for k in range(n)]
count = 0
for k in range(n):
	if st[k] == '0' or st[k] == '4' or st[k] == '8':
		count += 1
for k in range(2, n + 1):
	if int(st[n - k:n - k + 2]) % 4 == 0:
		count += n - k + 1
print(count)