#include <bits/stdc++.h>
using namespace std;
int main() {
  int int_h = 0;
  int int_m = 0;
  string h = "";
  string m = "";
  string str;
  cin >> str;
  h.push_back(str[0]);
  h.push_back(str[1]);
  m.push_back(str[3]);
  m.push_back(str[4]);
  int_h = (str[0] - '0') * 10 + (str[1] - '0');
  int_m = (str[3] - '0') * 10 + (str[4] - '0');
  int prev_h = int_h;
  int prev_m = int_m;
  if ((int_h == 23) && (int_m == 59)) {
    cout << "1";
    return 0;
  }
  int leaves = int_h % 10;
  int needs = int_h / 10;
  int current_h = leaves * 10 + needs;
  while (current_h != int_m) {
    if (int_m + 1 >= 60) {
      int_h = (int_h + 1) % 24;
    }
    int_m = (int_m + 1) % 60;
    leaves = int_h % 10;
    needs = int_h / 10;
    current_h = leaves * 10 + needs;
  }
  if (int_h < prev_h) {
    int_h += 24;
  }
  cout << (int_h - prev_h) * 60 + (int_m - prev_m);
  return 0;
}
