#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.length();
  vector<int> a(n);
  transform(s.begin(), s.end(), a.begin(), [](char c) { return c - '0'; });
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] % 4 == 0) ++ans;
  }
  for (int i = 1; i < n; ++i) {
    if ((10 * a[i - 1] + a[i]) % 4 == 0) ans += i;
  }
  cout << ans << '\n';
  return 0;
}
