#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 2;
char str[N];
int num = 0;
int main() {
  memset(str, 'a', sizeof(str));
  scanf("%s", str);
  int val = str[0] - '0';
  long long int mx = 0;
  if (val % 4 == 0) mx = 1;
  for (int i = 1; str[i + 1] != 'a'; i++) {
    int now = str[i] - '0', last = str[i - 1] - '0';
    num = last * 10 + now;
    if (now % 4 == 0) mx++;
    if (num % 4 == 0) mx += i;
  }
  printf("%lld", mx);
}
