#include <bits/stdc++.h>
using namespace std;
string addh(string h) {
  int hi = stoi(h) + 1;
  if (hi == 24) {
    hi = 0;
  }
  string h2;
  if (hi < 10) {
    h2 = "0" + to_string(hi);
  } else {
    h2 = to_string(hi);
  }
  return h2;
}
int f(string h, string m) {
  string h2(h);
  reverse(h2.begin(), h2.end());
  int hi = stoi(h2);
  int mi = stoi(m);
  if (mi <= hi && hi < 60) {
    return hi - mi;
  }
  return f(addh(h), "00") + 60 - mi;
}
int main() {
  string s;
  cin >> s;
  string h = s.substr(0, 2);
  string m = s.substr(3, 2);
  cout << f(h, m) << endl;
  return 0;
}
