#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 500005;
void Solve() {
  string s;
  cin >> s;
  int n = s.size();
  long long ans = 0;
  s = " " + s;
  for (int i = (1); i <= (n); i++) {
    int d = s[i] - '0';
    if (d % 4 == 0) ans++;
    if (i > 1) {
      int x = s[i - 1] - '0';
      x = x * 10 + d;
      if (x % 4 == 0) ans += i - 1;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) Solve();
}
