#include <bits/stdc++.h>
using namespace std;
int const Max_N = 3e5 + 5;
char s[Max_N];
int main() {
  scanf("%s", s);
  long long ans = 0;
  int n = strlen(s);
  for (int i = 0; i < n - 1; ++i) {
    int num = (s[i] - '0') * 10 + (s[i + 1] - '0');
    if (num % 4 == 0) ans += i + 1;
  }
  for (int i = 0; i < n; ++i)
    if ((s[i] - '0') % 4 == 0) ++ans;
  cout << ans << endl;
  return 0;
}
