#include <bits/stdc++.h>
using namespace std;
const bool testcases = 1;
unsigned long long int logn(unsigned long long int n,
                            unsigned long long int r) {
  return (n > r - 1) ? 1 + logn(n / r, r) : 0;
}
int powmod(long long int x, unsigned long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  long long int dp = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i - 1] == '4' || s[i - 1] == '8' || s[i - 1] == '0') dp++;
    if (i != 1 && ((s[i - 2] - '0') * 10 + (s[i - 1] - '0')) % 4 == 0)
      dp += i - 1;
  }
  cout << dp;
  return 0;
}
