#include <bits/stdc++.h>
char s[300005];
using namespace std;
int main() {
  while (~scanf("%s", s)) {
    int l = strlen(s);
    long long sum = 0;
    for (int i = 0; i < l; i++) {
      if ((s[i] - '0') % 4 == 0) {
        sum++;
      }
    }
    for (int i = 0; i < l; i++) {
      if (s[i] == '4' || s[i] == '0' || s[i] == '8') {
        if ((s[i - 1]) % 2 == 0) {
          sum += i;
        }
      } else if (s[i] == '2' || s[i] == '6') {
        if ((s[i - 1] - '0') % 2 == 1) {
          sum += i;
        }
      }
    }
    cout << sum << endl;
  }
}
