#include <bits/stdc++.h>
using namespace std;
long long int fact(long long int n) {
  if (n == 0 || n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
int gcd(int a, int b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  if (a == 1 || b == 1)
    return 1;
  else if (a == 0 && b != 0)
    return b;
  else if (b == 0 && a != 0)
    return a;
  else {
    int r = a > b ? a % b : b % a;
    if (r == 0)
      return min(a, b);
    else
      return gcd(min(a, b), r);
  }
}
int main() {
  string s;
  cin >> s;
  long long int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] - 48) % 4 == 0) cnt++;
    if (i != 0) {
      int u = s[i] - 48, t = s[i - 1] - 48;
      if ((t * 10 + u) % 4 == 0) cnt += i;
    }
  }
  cout << cnt;
  return 0;
}
