#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int temp;
  long long sol = 0;
  cin >> s;
  if ((s[0] - '0') % 4 == 0) {
    sol++;
  }
  for (int a = s.length() - 1; a > 0; a--) {
    temp = (s[a] - '0') + 10 * (s[a - 1] - '0');
    if (temp % 4 == 0) {
      sol += a;
    }
    if ((s[a] - '0') % 4 == 0) {
      sol++;
    }
  }
  cout << sol << '\n';
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
