s = input()
n = len(s)
ans = 0
for i in range(n-1,-1,-1):
b = int(s[i])
if b%4==0:
ans+=1
if i:
a = int(s[i-1])
num = a*10+b
if num%4==0:
ans+=i
print(ans)
#include<bits/stdc++.h>
#define ll long long
#define sz size()
#define vt vector
#define ct const
#define pb push_back
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll t, n, m, i, j, r1 = 0, ans, l, als = 0, r2, r3, r4, k, mnn, ii, x, y;
string d1, d2, d3, d4;
int main()
{
Fast;
cin >> d1;
ans = 0;
n = d1.size() - 1;
for(i=0;i<=n;i++){
if(int(d1[i] - 48) % 4 == 0)ans++;
}
for(i=0;i<n;i++){
r1 = int(d1[i] - 48)*10 + int(d1[i+1] - 48);
// cout << r1 << " ";
if(r1 % 4 == 0){
ans += i+1;
}
}
cout << ans ;
return 0;
}
/**--|-name---8--8---!---!---!---!---8--8---name-|--**/
//---|-name---8--8---!---!---!---!---8--8---name-|--///
//---|--------0--8-------------------8--0--------|--///
//---|--------0--8-(Welcome-To-Code)-8--0--------|--///
//---|--------0--8-------------------8--0--------|--///
//---|-name---8--8---!---!---!---!---8--8---name-|--///
/**--|-name---8--8---!---!---!---!---8--8---name-|--**/
/**--|-------------------------------------------|--**/
/**--|------(-DoN'T-GivE-Up-YoU-Can-DO-iT-)------|--**/
/**--|-------------------------------------------|--**/
/**--|-name---8--8---!---!---!---!---8--8---name-|--**/
/**--|-name---8--8---!---!---!---!---8--8---name-|--**/
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |
1649A - Game | 139A - Petr and Book |
1612A - Distance | 520A - Pangram |
124A - The number of positions | 1041A - Heist |
901A - Hashing Trees | 1283A - Minutes Before the New Year |
1654D - Potion Brewing Class | 1107B - Digital root |
25A - IQ test | 785A - Anton and Polyhedrons |
1542B - Plus and Multiply | 306A - Candies |
1651C - Fault-tolerant Network | 870A - Search for Pretty Integers |
1174A - Ehab Fails to Be Thanos | 1169A - Circle Metro |