#include <bits/stdc++.h>
using namespace std;
bool isFile = 0;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (isFile) {
    freopen(
        "A"
        ".in",
        "r", stdin);
    freopen(
        "A"
        ".out",
        "w", stdout);
  }
}
void solve() {
  long long ans = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] - '0') % 4 == 0) {
      ans++;
    }
    if (i > 0) {
      long long t = s[i] - '0' + 10 * (s[i - 1] - '0');
      if (t % 4 == 0) {
        ans += i;
      }
    }
  }
  cout << ans;
}
int main() {
  faster();
  int t = 1;
  while (t--) solve();
}
