#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int N = 1000 + 5;
int32_t main() {
  string s;
  cin >> s;
  long long int n = s.size();
  long long int ans = (s[0] % 4 == 0);
  for (long long int i = 0; i < n - 1; i++) {
    long long int first = s[i] - '0';
    long long int second = s[i + 1] - '0';
    if (second % 4 == 0) ans++;
    if ((first * 10 + second) % 4 == 0) ans += i + 1;
  }
  cout << ans << '\n';
  return 0;
}
