#include <bits/stdc++.h>
using namespace std;
bool ispalin(string s) { return (s[0] == s[4] && s[1] == s[3]); }
int main() {
  string s;
  cin >> s;
  int s_h = atoi(s.substr(0, 2).c_str());
  int s_m = atoi(s.substr(3, 2).c_str());
  for (int h = 0; h <= 23; h++) {
    for (int m = 0; m <= 59; m++) {
      string c = "";
      if (h < 10)
        c += "0" + to_string(h);
      else
        c += to_string(h);
      c += ":";
      if (m < 10)
        c += "0" + to_string(m);
      else
        c += to_string(m);
      if (c >= s && ispalin(c)) {
        int num_mins = (h - s_h) * 60 + (m - s_m);
        cout << num_mins << endl;
        return 0;
      }
    }
  }
  int num_mins = (24 - s_h) * 60 - s_m;
  cout << num_mins << endl;
  return 0;
}
