#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, i;
  while (~scanf("%d:%d", &hh, &mm)) {
    mm = mm - 1;
    for (i = 0;; i++) {
      mm++;
      if (mm >= 60) {
        mm = mm - 60;
        hh++;
        if (hh >= 24) hh = 0;
      }
      if (hh / 10 == mm % 10 && hh % 10 == mm / 10) {
        cout << i << endl;
        return 0;
      }
    }
  }
}
