#include <bits/stdc++.h>
using namespace std;
long long n, i, a, b, m, j, ans;
string s;
int main() {
  cin >> s;
  if ((s[0] - '0') % 4 == 0) ans++;
  for (i = 1; i < s.size(); i++) {
    if ((10ll * (s[i - 1] - '0') + (s[i] - '0')) % 4 == 0) ans += i;
    if ((s[i] - '0') % 4 == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
