#include <bits/stdc++.h>
using namespace std;
int const N = 312312;
int const INF = 1e9 + 7;
bool ok(char a, char b) {
  int x = int(a - '0');
  int y = int(b - '0');
  return ((x * 2 + y) % 4 == 0);
}
string s;
long long ans;
int n;
int main() {
  cin >> s;
  n = s.size();
  for (int c = 0; c < s.size(); c++) {
    if (c == 0) {
      int x = int(s[c] - '0');
      if (x % 4 == 0) ans++;
    } else {
      int x = int(s[c] - '0');
      if (x % 4 == 0) ans++;
      if (ok(s[c - 1], s[c])) {
        ans += c * 1LL;
      }
    }
  }
  cout << ans;
  return 0;
}
