#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1000000000000000000;
#pragma GCC optimize("-O3")
long long int gen() {
  long long int temp;
  cin >> temp;
  return temp;
}
long long int power(long long int a, long long int b, long long int m) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % m;
      b--;
    }
    a = (a * a) % m;
    b = b >> 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int res = 0;
  long long int n = s.length();
  for (long long int i = n - 1; i >= 0; i -= 1) {
    if ((s[i] - '0') % 4 == 0) res++;
    if (i - 1 >= 0 and ((s[i - 1] - '0') * 10 + (s[i] - '0')) % 4 == 0)
      res += i;
  }
  cout << res << "\n";
  return 0;
}
